Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-07-19 09:41:21

From: "Ed Brey" <brey_at_[hidden]>
> "Peter Dimov" <pdimov_at_[hidden]> wrote in message
> >
> > This comes at a cost. counted_base::release() const implies
> > counted_base::dispose() const. The function that dispose() performs is
> > release any resources managed by the object. Hence, these resources
> > need to be made mutable, and const correctness goes MIA.
> Why is dispose() used to release resources, rather than the destructor?
It would be nice to not have dispose(), so that classes that faithfully
clean up via their distructors don't have to pay for dispose() (fortunately,
it's quite minimal, anyway).

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.

> 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

Could you elaborate? What does "not using counted_base" mean here? This may
be a bug.

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