Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-03-21 10:30:58


Daniel Frey:

> Hi,
>
> is there any reason why shared_ptr does not have a ctor that takes an
> auto_ptr and a deleter?

shared_ptr assumes that an object that is owned by an auto_ptr needs to be
destroyed by delete, because that is what the auto_ptr would do if, for
example, an exception is thrown before the line that transfers the ownership
to a shared_ptr.

> I also wonder if there is a resource leak if I just write:
>
> auto_ptr<T> a = ...;
> my_deleter d = ...;
>
> shared_ptr<T> s( a.release(), d );

No, there isn't.


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