Boost logo

Boost Users :

Subject: Re: [Boost-users] how to delete references to objects from a container...
From: rv_nath (rv_nath_at_[hidden])
Date: 2009-12-09 10:44:36

Dear Jeff,
Thanx for your quick reply. FUrther to the same question,
can you please explain:
> There is also weak_ptr originally intended to break cycles which may be
of use to you.
  - the meaning of breaking cycles, and how it can help in this situation.

It is said that a weak ptr doesn't increment the refcount. That means there
is a possibility of the pointee object being deleted, while a weak ptr is
holding a reference of it. 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


Jeff Flinn wrote:
> rv_nath wrote:
>> Hi forum members,
>> I want to use boost's shared_ptr class for the connection pool class that
>> i
>> am writing. However, i have a requirement to delete the connection
>> object
>> (which is going to be the shared-ptr) explicitly based on certain checks
>> like validity and expiry etc. If I store the shared_ptr, I want to know
>> how
>> to delete this explicitly from the stl container.
>> According to my understanding shared_ptrs cannot be 'delete'd. So, how
>> to
>> achieve this...?
> shared_ptr's CAN be deleted(or reset to NULL), you can NOT directly
> delete the shared item that the shared_ptr is managing. When the last
> shared_ptr referencing the shared item is deleted(or reset) it will
> delete the shared item. There is also weak_ptr originally intended to
> break cycles which may be of use to you. Otherwise your design will need
> to communicate when to take appropriate actions.
> Jeff
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]

View this message in context:
Sent from the Boost - Users mailing list archive at

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at