std::unique_ptr
is indeed the new recommended way. With C++0x containers will become move-aware, meaning that they can handle types which are movable correctly (i.e., std::vector<std::auto_ptr<x> >
does not work, but std::vector<std::unique_ptr<x>>
will).
For boost
, the boost::interprocess
containers already support movable types, where boost::interprocess::unique_ptr
is one of them. They resemble movable types in pre C++0x by using some of the "normal" boost-template wizardry, and use r-value references where they are supported.
I didn't know about the auto_ptr
dedicated deprecation, though, but I've not followed the new standard evolution closely.
(edit) The implementation of boost::interprocess::unique_ptr
is indeed not a "public" smart-pointer like boost::shared_ptr
or boost::scoped_ptr
, but it is (see boost.interprocess's site) not just for shared-memory, but can also be used for general-purpose.
However, I'm quite sure that if GCC deprecates the auto_ptr
template, they already provide their own unique_ptr
implementation (not much use to deprecate if you not have a viable alternative yet).
However, that all being said, if you're working on a C++0x platform, use unique_ptr
, available from the compiler's lib, if not, stick with auto_ptr
.