intrusive_ptr and NULL value
Hi, guys! I found embarrassing difference between shared_ptr::operator*() and intrusive_ptr::operator*() behavior (even the same I can say about operator ->). At first, look on shared_ptr: reference operator* () const // never throws { BOOST_ASSERT(px != 0); return *px; } If shared_ptr object has NULL value and someone call operator*(), it will throws exception. But if we look on intrusive_ptr(): T & operator*() const { return *p_; } we can see, that pointer don't checks.... Is it an imperfection or a feature?
Pavel Syomin wrote:
If shared_ptr object has NULL value and someone call operator*(), it will throws exception. But if we look on intrusive_ptr(): T & operator*() const { return *p_; } we can see, that pointer don't checks.... Is it an imperfection or a feature?
Imperfection. This is actually already fixed in CVS as a response to a SF tracker item but it seems that the change was too late for 1.34. http://boost.cvs.sourceforge.net/boost/boost/boost/intrusive_ptr.hpp?r1=1.22&r2=1.23
participants (2)
-
Pavel Syomin
-
Peter Dimov