- 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?
Will auto_ptr be deprecated in incoming C++ standard? Should unique_ptr be used for ownership
Share
UPDATE: This answer was written in 2010 and as anticipated
std::auto_ptrhas been deprecated. The advice is entirely valid.In C++0x
std::auto_ptrwill be deprecated in favor ofstd::unique_ptr. The choice of smart pointer will depend on your use case and your requirements, withstd::unique_ptrwith move semantics for single ownership that can be used inside containers (using move semantics) andstd::shared_ptrwhen 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.