Boost logo

Boost Users :

From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2008-06-24 01:06:31

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.



Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at