I need to store the structure for Quadtree in shared memory.
It is a class with 4 pointers for tree-node regions and vector of points:
class CSNode4
{
...
CSNode4* node0;
CSNode4* node1;
CSNode4* node2;
CSNode4* node3;
vector<vec2> pointArray;
};
I have tried with
class CSNode4
{
...
offset_ptr<CSNode4> node0;
offset_ptr<CSNode4> node1;
...
};
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 OK until I try to static_cast node0:
offset_ptr<CSNode4> N1 = static_cast<CSNode4*>(rootNode->node0);
I get:
error C2440: 'static_cast' : cannot convert from 'boost::interprocess::offset_ptr' to 'CSNode4 *'
(MSVC 2010, boost 1.42)
What am I doing wrong and how can I fix it?