Is auto_ptr deprecated?

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.

Leave a Comment