Why does unique_ptr have an overload for auto_ptr?

I got a compiler error and noticed something interesting. For some reason, unique_ptr has overloaded for auto_ptr , but I thought auto_ptr deprecated:

 /usr/local/include/c++/4.9.0/bits/unique_ptr.h:228:2: note:template<class _Up, class> std::unique_ptr<_Tp, _Dp>::unique_ptr(std::auto_ptr<_Up>&&) unique_ptr(auto_ptr<_Up>&& __u) noexcept; /usr/local/include/c++/4.9.0/bits/unique_ptr.h:228:2: note: template argument deduction/substitution failed: main.cpp:41:67: note: mismatched types 'std::auto_ptr<T>' and 'char*' 

Is it due to backward compatibility with the code that used auto_ptr ?

+5
source share
1 answer

Yes, it is for interaction with auto_ptr and obsolete tools (in accordance with the standard)

Normative for the current edition of the standard, but not guaranteed to be part of the Standard in future versions.

+2
source

Source: https://habr.com/ru/post/1203531/


All Articles