Boost logo

Boost Users :

Subject: [Boost-users] Problem with Interpocess offset_ptr
From: mike_at_[hidden]
Date: 2011-12-26 05:49:54


Hi,
I need to store in the shared memory structure for Quadtree.
It is a class with 4 pointers for tree regions and vector of points:
class CNode4
{
...
 CNode4* node0;
 CNode4* node1;
 CNode4* node2;
 CNode4* node3;
 vector<vec2> pointArray;
};

I have tried with
class CNode4
{
...
 offset_ptr<CSNode4> node0;
...
};

and using as:
typedef allocator<void, managed_shared_memory::segment_manager>
void_allocator;
const void_allocator alloc_void(segment.get_segment_manager());
CSNode4* rootNode = segment.construct<CSNode4> (_RootNode) (alloc_void);
rootNode->node0 = new CSNode4(alloc_void,...);

this works until I try to static_cast node0
offset_ptr<CSNode4> N1 = static_cast<CSNode4*>(rootNode->node0);
I get:
(MSVC 2010, boost 1.42)
 error C2440: 'static_cast' : cannot convert from
'boost::interprocess::offset_ptr<PointedType>' to 'CSNode4 *'

what am I doing wrong?
Thanks,
Ivan


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