[C++-sig] Re: reference counting pointers
David Abrahams
dave at boost-consulting.com
Fri Jul 18 18:16:55 CEST 2003
"Dusty Leary" <dleary at ttlc.net> writes:
>>
>> Try
>>
>> implicitly_convertible<intrusive_ptr<B>, intrusive_ptr<A> >();
>>
>> Of course, if you just use shared_ptr instead, none of that is needed
>> ;-)
>>
>
> why does it work automatically with shared_ptr and not with intrusive_ptr?
Because shared_ptr is special, and can do so safely. The shared
pointer always manages the owning Python object, while intrusive_ptr
can't do that, and there's no guarantee that a derived-to-base
conversion on intrusive_ptr is safe (there might be no virtual
destructor in the base class).
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list