From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-12-07 12:14:05
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 it does, but when your source is a temporary, it doesn't make any
difference; even if it's left unchanged by the constructor, it will be
destroyed at the end of the full expression, along with the pointee.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk