[interprocess] [shared_ptr] Failure to type convert offset_ptr<T> to T *

The failure is in sp_counted_impl.hpp:66: 64 template<class Ptr> 65 sp_counted_impl_pd(const Ptr & p, const A &a, const D &d ) 66 : this_allocator(a), D(d), m_ptr(p.get()) 67 {} p is of type offset_ptr<T> and m_ptr is of type T * Test case source, compiler output and quick fix patch (which is not fully correct, I suspect) are attached. $ g++ --version g++ (GCC) 4.2.3 (Debian 4.2.3-2) Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Aleksey Midenkov wrote:
The failure is in sp_counted_impl.hpp:66:
64 template<class Ptr> 65 sp_counted_impl_pd(const Ptr & p, const A &a, const D &d ) 66 : this_allocator(a), D(d), m_ptr(p.get()) 67 {}
p is of type offset_ptr<T> and m_ptr is of type T *
Test case source, compiler output and quick fix patch (which is not fully correct, I suspect) are attached.
If you want to place the a shared_ptr in shared memory you must define a deleter whose pointer type is offset_ptr because otherwise, that shared_ptr can't be shared between processes if they map the memory in different address. You should define the deleter storing a shared_ptr. Anyway, I think you are using quite an old Interprocess version, because shared_segment_deleter does not exist currently. Download a up-to-date version from Boost SVN or the Boost 1.35 release candidate 2. Here's a link to the documentation about shared_ptr: http://igaztanaga.drivehq.com/interprocess/interprocess/interprocess_smart_p... Regards, Ion
participants (2)
-
Aleksey Midenkov
-
Ion Gaztañaga