错误:不推荐使用'template <class> class std :: auto_ptr'

ord*_*e.r 7 c++ g++ scons c++11

我正在使用scons和ubuntu.当我在使用'scons'制作一些程序时,会发生错误,如:

src/db/DBTextLoader.cc:296:3:错误:'模板类std :: auto_ptr'已弃用[-Werror = deprecated-declarations]

/usr/include/c++/5/bits/unique_ptr.h:49:28:注意:在这里声明模板类auto_ptr;

这是我的命令;

$ ./configuer

$ source something.sh

$ scons

实际上,我什么都不知道.我已经在搜索这个网站和谷歌了.但我没有找到解决方案.

这是我的g ++版本(和c ++也是同一个版本.)

g ++(Ubuntu 5.4.0-6ubuntu1~16.04.4)5.4.0 20160609

有什么想法吗?谢谢.

ban*_*a36 8

如果您阅读Scott Meyers的一些书籍,他强烈建议不要使用auto_ptr.实际上,新的编译器可能会限制它的使用,因为auto_ptr在STL容器中使用时会出现很多可能的问题.

相反,std::unique_ptr如果您不想要更多的对象副本,并且std::shared_ptr需要复制指针,则应该使用.