Jason Sachs wrote:
Thanks, that helps. I didn't know you could use void_allocators, I thought they had to be specific for each allocated type. One question: I noticed in the example you posted, that the lifetime of the allocator "alloc_inst" equals/exceeds the lifetime of the map and the values that are inserted into the map. Is this required, or can the allocator just be a temporary stack variable (as follows)?
char_string key_object(void_allocator(segment.get_segment_manager()));
Just like standard allocators the container makes an internal copy of the arguments (allocator or comparison function for associative containers), so you can initialize it with a variable in the stack. The goal is to create a container in shared memory and it will hold the allocator internally. Regards, Ion