I use boost multi_index in boost managed_shared_memory.
One of the data i save in the container is a pointer to a class allocated in shared memory.
The container and the pointer are in the same segment.
The container is used from multiple process.
So one process can create this pointer and another delete.
I take care of multiple access.
My problem is about sharing pointer address between process.
I understand that each process can map the shared memory at different process' address space.
So i can't save the pointer as it is.
Is this a good idea to save offset between segment and pointer?
bip::offset_ptr<MyType> MyTypeOffset = l_pMyType;
bip::offset_ptr<bip::managed_shared_memory> SegmentOffset = m_pSegmentManager;
OffsetFromSegment = MyTypeOffset - SegmentOffset;
And in process that read this from shared memory
MyType * pMytype = m_pSegmentManager + OffsetFromSegment;