std::auto_ptr
is broken in VC++ 8 (which is what we use at work). My main gripe with it is that it allows auto_ptr
, which of cour
Move to boost smart pointers.
In the meantime, you may want to extract a working auto_ptr implementation from an old / another STL, so you have working code.
I believe that auto_ptr semantics are fundamentally broken - it saves typing, but the interface actually is not simpler: you still have to track which instance is the current owner and make sure the owner leaves last.
unique-ptr "fixes" that, by making release not only give up ownership, but also setting the RHS to null. It is the closest replacement for auto-ptr, but with its different semantics it is not a drop-in replacement.
There's an introductory article to boost smart pointers, by, ahem, me.