Boost logo

Boost :

From: Sean Kelly (sean_at_[hidden])
Date: 2004-01-14 19:46:25


Currently, there's no way to force a shared_ptr to release something once
it has been given ownership of it. I've run into instances where I use a
shared_ptr to hold an object in an STL container and then I want to pass
it on to another code segment. While I could pass a shared_ptr, I would
prefer to use auto_ptr to convey that ownsership is indeed being
transferred. This is particularly important in a few cases where the
transferral is between threads and I don't want to use an interlocked
version of shared_ptr.

I understand the danger of providing such a method, but to me the presense
of use_count() and unique() implies that there are instances where the
programmer might want to do something like this. Are there any other
reasons why a release method hasn't been included aside from the
possibility of double destruction?

Sean


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk