Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2002-06-19 04:10:32

"Markus Schöpflin" <markus.schoepflin_at_[hidden]> wrote in message
> [...]
> BTW, is there any documentation on using the intrusive features of
> the new shared_ptr? Or isn't it supposed to be used outside the
> implementation?

I think right now the code is the documentation. ;) The intrusive
features were created to support intrusive_ptr, which allows you
to derive a class from boost::counted_base, which stores the
count with your object, instead of externally. You can create a
shared_ptr from an intrusive_ptr (it will automagically use the
intrusive count).

That pretty much tells you what you need to know to use it (and
you can always look at the code if you're not sure about something...
the intrusive pointer is pretty short and straightforward).

Here's an example:

class foo : boost::counted_base

    boost::intrusive_ptr<foo> p(new foo);
    // count is 1
        boost::shared_ptr<foo> q(p);
        // count is 2
    // count is 1
// count is 0, foo destroyed


Boost list run by bdawes at, gregod at, cpdaniel at, john at