17 May
2005
17 May
'05
12:01 a.m.
Jean-François Brouillet wrote:
As observed in another thread, the intrusive_ptr destructor in boost 1.32 does not honor its own status as defined in the constructor with respect to the addRef boolean.
This snippet shows the problem:
X * x = new X ; { intrusive_ptr<X> p(x, false) ; }
// Here, x has been destroyed!
Is this a bug, or some requirement (that I couldn't find) that if you ever pass "false" to the constructor, then that intrusive_ptr is assumed to never go out of scope?
http://boost.org/libs/smart_ptr/intrusive_ptr.html#constructors add_ref == false means that you (or someone else) already called addref on the pointer. It's typically used with factory functions that return addref'ed pointers.