Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-05-16 19:01:19


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.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net