
"Peter Dimov" <pdimov@mmltd.net> writes:
Yuval Ronen wrote:
I just thought that if we combine this with the conclusion of the discussion about temporary auto_ptrs being passed to shared_ptr constructors (with the '.release()'), then the result is that I can't assign a temporary auto_ptr to a shred_ptr.
If I had a reset(auto_ptr<Y> &), then I could call it with .release(), but since all I have is operator=(auto_ptr<Y> &), I can't use .release(), as I don't have operator=(Y*).
No temporary auto_ptrs for me... :-(
You can use px.reset( function().release() ), as there is a reset( Y* ).
I feel compelled to point out that this idiom opens exception safety holes where the other one wouldn't. Exception-safe resource management is, after all, an important role for smart pointers. -- Dave Abrahams Boost Consulting www.boost-consulting.com