如何使用-std = c ++ 11解决g ++警告:不推荐使用'auto_ptr'

时间:2015-04-25 13:12:23

标签: c++ c++11 g++

使用-std=c++11编译器尝试g++,我有很多

warning: ‘auto_ptr’ is deprecated (declared at 
/usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations]

我应该使用什么而不是auto_ptr?请提供信息链接或完整答案。

2 个答案:

答案 0 :(得分:3)

您可以使用std::unique_ptr代替std::auto_ptr

如果您复制了auto_ptr,则必须std::move unique_ptr

答案 1 :(得分:2)

  

"我应该使用什么而不是auto_ptr?"

代表std::auto_ptr<>行为的类最为std::unique_ptr<>

相关问题