Boost logo

Boost Users :

From: Berenguer Blasi (bblasi_at_[hidden])
Date: 2006-07-20 11:50:28


Sure Ion,

thanks for answering.

Commenting or uncommenting the last line (the one with insert) you get the
compilation error.

I don?t know how to insert something into the multimap...

Thanks in advance

(I tried to follow the code behind flat_tree but got confused as I think a
std::pair is what's expected??)

---------------

#include <vector>
#include <boost/shmem/named_shared_object.hpp>
#include <boost/shmem/containers/string.hpp>
#include <boost/shmem/containers/flat_set.hpp>
#include <boost/shmem/containers/flat_map.hpp>
#include <boost/shmem/allocators/allocator.hpp>
#include <boost/shmem/offset_ptr.hpp>
#include <boost/functional/hash.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/member.hpp>

class myShmNode
{
        //whatever
};
typedef boost::shmem::allocator<myShmNode *,
boost::shmem::named_shared_object::segment_manager> myShmNodePtrAllocator;
typedef boost::shmem::flat_multimap<size_t, myShmNode*,
std::less<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<myShmNode*> comparator2;
MyMultiMap*
ptrsMultiMap=segment.construct<MyMultiMap>(boost::shmem::anonymous_instance)
(comparator2,nodesPtrsAllocator);

typedef std::pair<size_t,myShmNode*> multiMapNodeType;
multiMapNodeType multiMapNode;

myShmNode* myNode;
multiMapNode.first = 1;
multiMapNode.second = myNode;

ptrsMultiMap->insert(multiMapNode);

}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net