
Sorry to bother with this questions... What I am trying to do is: Share MAP objects between several process, the map I need to share is something like this: map<string, Employee> myMap; String is the key and the value has to be a custom class or a struct... I tried this but I got lots of errors: struct Employee { std::string name; int age; }; managed_shared_memory segment(create_only, "MySharedMemory", 65536); typedef std::pair<boost::interprocess::basic_string, Employee> ValueType; typedef allocator<ValueType, managed_shared_memory::segment_manager> ShMemAllocator; typedef map<StrAllocator, EmpAllocator, NULL, ShMemAllocator> MyMap; ShMemAllocator alloc_inst (segment.get_segment_manager()); MyMap m*mymap = segment.construct<MyMap>("MyMap")(alloc_inst); //to insert just one value: Employee John; john.name = "Johnny"; john.age = 25; mymap->insert(std::pair<"Hello", john>(boost::interprocess::basic_string, Employee); Actually I don't know what other path should I take on this... Could anyone please help me fix this portion of code? Thank you very much. Dann

Daniel Veneros <dann.vd <at> gmail.com> writes:
I tried this but I got lots of errors:
Sometimes it helps to include some of the errors you think are relevant. [snip]
typedef std::pair<boost::interprocess::basic_string, Employee> ValueType; [snip] MyMap m*mymap = segment.construct<MyMap>("MyMap")(alloc_inst);
I assume this was intended to be "MyMap *mymap = ..." [snip]
mymap->insert(std::pair<"Hello", john>(boost::interprocess::basic_string, Employee);
You have your types and values switched with the std::pair<> constructor. Try changing the last line to: mymap->insert(ValueType("Hello", john)); -Ryan
participants (2)
-
Daniel Veneros
-
Ryan Gallagher