|
Boost : |
From: Rene Rivera (grafik.list_at_[hidden])
Date: 2005-12-07 11:52:11
Yuval Ronen wrote:
> Peter Dimov wrote:
>
>>The reference adds a strong exception safety guarantee. If the shared_ptr
>>constructor fails, the source auto_ptr is left intact. Pass by value would
>>have already zeroed out the source.
>>
>>If you want to achieve the equivalent of pass by value, you can use an
>>explicit .release().
>>
>>This warning would actually be an error on a stricter compiler.
>>
>>One happy day the compiler writers will bring us the rvalue reference, the
>>constructor will take auto_ptr &&, and all will be well with the world. :-)
>
>
> Does that mean that on a stricter compiler, when passing a temporary
> auto_ptr, I *have* to use the '.release()' way, and *can't* get the
> strong exception guarantee?
Yes, and no. It means it can't be a temporary if you want the strong
exception guarantee. I.e. you would have to assign the temporary to an
lvalue first:
auto_ptr<X> a = returns_some_auto_ptr_x();
shared_ptr<X> b(a);
-- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim - Grafik/jabber.org
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk