|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-01-17 11:25:08
From: "Beman Dawes" <bdawes_at_[hidden]>
> At 09:59 AM 1/17/2002, Andrei Alexandrescu wrote:
>
> >> A smart shared_ptr can do the right thing on b.reset(), but on
> >b.release()
> >> the user will be left with a Base* and the undefined behavior is not
> far
> >> away.
> >
> >I agree that release() is dangerous. It is also required if you want to
> use
> >smart pointers with any COM (and, I suspect, CORBA) projects. The
typical
> >scenario (shown by Rob), is when you need to return a pointer in an out
> >parameter. In that case you need to tell your smart pointer you want to
> >take ownership of the pointee away from the smart pointer.
>
> Is this related to a specific policy instance? Can release() only be
> exposed in that particular policy instance? Thus shared_ptr and
> scoped_ptr, for example, wouldn't have release(), but an Ownership policy
> related to COM objects would expose release().
I am inclined to think that the choice whether to expose release() needs to
be orthogonal to the other policies.
-- Peter Dimov Multi Media Ltd.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk