Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-09-22 09:28:28

From: "Peter Dimov" <pdimov_at_[hidden]>

> From: "David Abrahams" <dave_at_[hidden]>
> >
> > If you derive from counted_base, what happens with weak_ptr?
> > It seems as though every live weak_ptr ends up keeping the object
> Weak pointers to intrusive counted objects require a bit of help from the
> user. As the count and the object are inseparable, a weak_ptr will keep
> whole object alive. However, counted_base::dispose will be called when
> use count drops to zero and only weak pointers to the object remain. If
> object manages any resources, it should override dispose() and release
> An important special case is that any shared_ptr members should be
> or potentuial cycles won't be broken.

Thanks, that's interesting. Also, I suppose, weak_ptr members /should/ be
reset for optimal behavior.
All this definitely pushes me towards using a free-function interface to
avoid the problem that 'this' cannot be a smart pointer. Seems like a much
cleaner approach to me.

           David Abrahams * Boost Consulting
dave_at_[hidden] *

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