4

Trying out -std=c++11 with the g++ compiler, I got lots of

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

What should I use instead of auto_ptr? Please give an informative link or a complete answer.

rwst
  • 2,515
  • 2
  • 30
  • 36

2 Answers2

4

You may use std::unique_ptr instead of std::auto_ptr

And if you copied auto_ptr, you have to std::move the unique_ptr.

Jarod42
  • 203,559
  • 14
  • 181
  • 302
2

"What should I use instead of auto_ptr?"

The class representing std::auto_ptr<>'s behavior most closely is std::unique_ptr<>.

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190