#include #include #include #include #include using namespace boost::interprocess; //Typedefs of allocators and containers typedef managed_shared_memory::segment_manager segment_manager_t; typedef allocator void_allocator; typedef allocator char_allocator; typedef basic_string, char_allocator> char_string; //Definition of the map holding a string as key and complex_data as mapped type typedef std::pair map_value_type; typedef allocator map_value_type_allocator; typedef map< char_string, int, std::less, map_value_type_allocator> complex_map_type; int main () { shared_memory_object::remove("MySharedMemory"); //Create shared memory managed_shared_memory segment(create_only,"MySharedMemory", 65536); //An allocator convertible to any allocator type void_allocator alloc_inst (segment.get_segment_manager()); //Construct the shared memory map and fill it complex_map_type *mymap = segment.construct("MyMap")(std::less(), alloc_inst); char_string cs("test", alloc_inst); for(int i = 0; i < 100; ++i) { mymap->insert(std::pair(cs , i)); } return 0; }