为什么unique_ptr有auto_ptr的重载?

use*_*715 5 c++ auto-ptr unique-ptr c++11

我收到编译错误,发现有趣的东西.由于某种原因unique_ptr有一个超载auto_ptr,但我认为auto_ptr已被弃用:

/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*'
Run Code Online (Sandbox Code Playgroud)

这是因为与使用的代码向后兼容auto_ptr吗?

Joh*_*erg 2

是的,它用于与 auto_ptr 的互操作,并且不推荐使用(根据标准)

本标准当前版本的规范性内容,但不保证成为未来修订版标准的一部分。