|
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
news:004c01c22f0b$bc8d0760$1d00a8c0_at_pdimov2...
> >
> > This comes at a cost. counted_base::release() const implies
> > counted_base::dispose() const. The function that dispose() performs is
to
> > release any resources managed by the object. Hence, these resources
would
> > 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
counted_base,
<
Could you elaborate? What does "not using counted_base" mean here? This may
be a bug.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk