Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error : ‘template<class> class std::auto_ptr’ is deprecated

Tags:

c++

c++11

g++

scons

I'm using scons and ubuntu. When i when i make some program in using 'scons', there happen error like,

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;

and this is my command;

$ ./configuer

$ source something.sh

$ scons

Actually, I don't have any idea. I'm already searching this site and google. But I didn't find solution.

this is my g++ version (and c++ also was same version.)

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

have any idea? Thank you.

like image 251
orde.r Avatar asked Jul 12 '17 09:07

orde.r


1 Answers

If you read some books of Scott Meyers, he strongly recommends not to use auto_ptr. Actually, new compilers may restrict it's usage because of lots of possible problems with it when using auto_ptr in STL containers, etc.

Instead, you should use std::unique_ptr if you don't want more that one copy of the object, and std::shared_ptr if you need to copy the pointer.

like image 156
banana36 Avatar answered Oct 04 '22 06:10

banana36