Boost logo

Boost Users :

Subject: Re: [Boost-users] how to delete references to objects from a container...
From: Igor R (boost.lists_at_[hidden])
Date: 2009-12-09 11:30:51


>  So, in my understanding, if i return a weak-ptr to the clients of my object, then I will be able to delete my object at time
> of my choosing inspite of how many number of weak-ptr references the clients may have. But after this, the weak-ptr reference becomes invalid. Am I right?

You never can *delete* an object (in the sense of invoking delete()
operator), which is accessed through shared_ptr. It can be deleted by
shared_ptr's deleter only.
If you return to your clients weak_ptr's to a "living" object, they
probably will lock() that weak_ptr in order to access the object, and
the object will be deleted only after all the clients dispose their
weak/shared ptrs.


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