boost::interprocess::managed_shared_ptr is not really a shared pointer; it's just a helper class that you can use to determine the type of one. From interprocess docs :
typedef managed_shared_ptr<MyType, managed_shared_memory>::type my_shared_ptr;
And creating a shared pointer can be simplified:
[C ++]
my_shared_ptr sh_ptr = make_managed_shared_ptr (segment.construct<MyType>("object to share")(), segment);
The following should work with the sh_ptr example from the above example:
typedef managed_shared_ptr<const MyType, managed_shared_memory>::type my_shared_const_ptr; my_shared_const_ptr sh_c_ptr = sh_ptr;
Because these two objects are common pointers.
On the other hand, doing:
managed_shared_ptr<MyType, managed_shared_memory> ptr; managed_shared_ptr<const MyType, managed_shared_memory> c_ptr = ptr;
will not work, because in this case ptr and c_ptr are very simple structures that do nothing but make 3 typedefs, so they wonβt convert.
Corey source share