
7 Dec
2005
7 Dec
'05
4:20 p.m.
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? Thanks a lot to both of you Peter and Howard for your help.