Boost logo

Boost :

From: Ed Brey (brey_at_[hidden])
Date: 2002-07-19 10:40:21


"Peter Dimov" <pdimov_at_[hidden]> wrote in message news:003301c22f32$5a210960$1d00a8c0_at_pdimov2...
>
> counted_base::dispose() is called when the last shared_ptr to the object
> dies. The destructor is called when the last weak or shared_ptr dies.
>
> It's a good idea to release resources in dispose(), and it's essential to
> reset() any shared_ptr members in order to avoid cycles.

Good explanation. Thanks.

> > 4. I was happy, except for the cases where I my new code had
> intrusive_ptr<T const>. So I changed those to back shared_ptr. I also
> noticed that given T const, shared_ptr silently pessimized by not using
> counted_base,
> <
>
> Could you elaborate? What does "not using counted_base" mean here? This may
> be a bug.

The shared_count constructor overload that takes counted_base* does not take counted_base const*, which is what it would get if the shared_ptr's template type is <T const>. Overload resolution then falls back on the templatized constructor, which uses the heap instead of counted_base.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk