Boost logo

Boost Users :

From: Bobby Thomale (bobby-thomale_at_[hidden])
Date: 2002-09-27 09:00:23


> 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 the
> whole object alive. However, counted_base::dispose will be called when the
> use count drops to zero and only weak pointers to the object remain. If the
> object manages any resources, it should override dispose() and release them.
> An important special case is that any shared_ptr members should be reset(),
> or potential cycles won't be broken.

Ah. So if I want to "destruct" my object when only weak pointers remain, I
should essentially move the contents of my destructor to dispose?

Will dispose get called once and only once, whether there are weak pointers
or not, when the last reference goes away and the ref count goes to 0?

Cool. I can live with that.

                                -- Bobby

---------------------------------------------------------------------
Bobby Thomale
Senior Software Developer
Inoveon Corporation
http://www.inoveon.com/
---------------------------------------------------------------------


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net