El 26/12/2011 11:49, mike@tesla.rcub.bg.ac.rs escribió:
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_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
(rootNode->node0); I get: (MSVC 2010, boost 1.42) error C2440: 'static_cast' : cannot convert from 'boost::interprocess::offset_ptr<PointedType>' to 'CSNode4 *'
You can't static cast between offset_ptrs (language limitations,
supporting static_cast would allow unwated conversions). But you can
convert offset_ptr to a raw pointer, static cast it and assign it to a
offset_ptr again:
offset_ptr<CSNode4> N1 = static_cast