How can i access the offset_ptr of the object which is created in the shared memory?
segment = new managed_shared_memory(create_only, "MySharedMemory", segmentSize);
line = 开发者_运维知识库segment->construct<Line>("Line1")("line");
I want to access of offset_ptr for Line object..
First, you need to declare the offset pointer with your Line type:
boost::interprocess::offset_ptr<Line> offset_p;
Second, you assign it:
offset_p = line;
Now, offset_p holds an offset from from line to itself, so you can get a pointer to line and use it in any process like this:
draw_line( offset_p.get() );
精彩评论