|
Boost Users : |
From: Wolfgang Hottgenroth (woho_at_[hidden])
Date: 2007-01-19 11:10:19
Hi,
I'm a complete newbie with boost and have a question concerning the
interprocess stuff.
I took the piece of code to share a vector in shared memory between two
processes from the quick-start guide as a start point and it compiled
and ran immediately with success for me.
Then I tried to replace the vector by a map:
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/containers/map.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
using namespace std;
int main ()
{
boost::interprocess::shared_memory_object::remove("MySharedMemory");
boost::interprocess::managed_shared_memory
segment(boost::interprocess::create_only, "MySharedMemory"
,65536); //segment size in bytes
typedef pair<const int, int> MyPair;
typedef boost::interprocess::allocator<MyPair,
boost::interprocess::managed_shared_memory::segment_manager> ShmemAllocator;
typedef boost::interprocess::map<int, int, less<int>, ShmemAllocator>
MyMap;
const ShmemAllocator alloc_inst (segment.get_segment_manager());
MyMap *mymap = segment.construct<MyMap>("MyMap")(alloc_inst);
// mymap->insert(make_pair(1,10));
// mymap->insert(make_pair(2,20));
// mymap->insert(make_pair(3,30));
// mymap->insert(make_pair(4,40));
// mymap->insert(make_pair(5,50));
return 0;
}
and I wasn't able to compile it any more. (I've put the error message
and the sources on the web, find it here: http://www.hottis.de/boost/)
I think it is the segment.construct line, although I don't find a direct
hint in the error message from the compiler, but if I comment out this
line, the compiler is happy.
Has any one any hint for me?
Thank you very much,
Wolfgang
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