Hi Berenguer,
flat_map has the same interface as map so if you have more problems, try
to make an small example using map. Regarding flat_xxx family:
The comparison function must compare keys, not mapped types:
std::less
The allocator must allocate pairs:
allocator , segment_manager>
if you were using boost::shmem::map the stored objects are const keys so
you would need
allocator , segment_manager>
This is your modified example. Compiles fine in Visual 7.1. I left
commented the code I've changed:
#include <vector>
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
class myShmNode
{
//whatever
};
typedef boost::shmem::allocator
/*myShmNode **/
,boost::shmem::named_shared_object::segment_manager>
myShmNodePtrAllocator;
typedef boost::shmem::flat_multimap
std::size_t/*myShmNode**/
,myShmNodePtrAllocator> MyMultiMap;
int main(int argc, char *argv[])
{
boost::shmem::named_shared_object segment;
segment.create( "/MySharedMemory", 1048576 );
//Initialize shared memory STL-compatible allocators
myShmNodePtrAllocator nodesPtrsAllocator(segment.get_segment_manager());
std::less comparator2;
MyMultiMap* ptrsMultiMap
= segment.construct<MyMultiMap>
(boost::shmem::anonymous_instance)
(comparator2,nodesPtrsAllocator);
typedef std::pair multiMapNodeType;
multiMapNodeType multiMapNode;
myShmNode* myNode;
multiMapNode.first = 1;
multiMapNode.second = myNode;
ptrsMultiMap->insert(multiMapNode);
}