我正在使用 scons 和 ubuntu。 当我使用'scons'制作一些程序时,会发生错误,例如,
src/db/DBTextLoader.cc:296:3: error: ‘template class std::auto_ptr’ is deprecated [-Werror=deprecated-declarations]
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here template class auto_ptr;
这是我的命令;
$ ./configuer
$ source something.sh
$ scons
其实我也不知道。我已经在搜索这个网站和谷歌了。但是我没有找到解决方案。
这是我的 g++ 版本(和 c++ 也是相同的版本。)
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
有什么想法吗? 谢谢。
最佳答案
如果你读过 Scott Meyers 的一些书,他强烈建议不要使用 auto_ptr
。实际上,新的编译器可能会限制它的使用,因为在 STL 容器等中使用 auto_ptr
时可能会出现很多问题。
相反,如果您不想要对象的多个拷贝,则应使用 std::unique_ptr
,如果需要复制,则应使用 std::shared_ptr
指针。
关于c++ - 错误 : ‘template<class> class std::auto_ptr’ is deprecated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45053626/