Is auto_ptr deprecated?

auto-ptr, c++, smart-pointers, standards, unique-ptr

Solution

UPDATE: This answer was written in 2010 and as anticipated `std::auto_ptr` has been deprecated. The advice is entirely valid.

In C++0x `std::auto_ptr` will be deprecated in favor of `std::unique_ptr`. The choice of smart pointer will depend on your use case and your requirements, with `std::unique_ptr` with move semantics for single ownership that can be used inside containers (using move semantics) and `std::shared_ptr` when ownership is shared.

You should try to use the smart pointer that best fits the situation, choosing the correct pointer type provides other programmers with insight into your design.

Problem

- Will auto_ptr be deprecated in incoming C++ standard? - Should unique_ptr be used for ownership transfer instead of shared_ptr? - If unique_ptr is not in the standard, then do I need to use shared_ptr instead?

Original source