如何使用 -std=c++11 解决 g++ 警告:'auto_ptr' 已弃用
how to resolve g++ warning with -std=c++11: ‘auto_ptr’ is deprecated
尝试使用 g++
编译器 -std=c++11
,我得到了很多
warning: ‘auto_ptr’ is deprecated (declared at
/usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations]
我应该用什么代替 auto_ptr
?请提供信息 link 或完整的答案。
"What should I use instead of auto_ptr
?"
最接近std::auto_ptr<>
行为的class是std::unique_ptr<>
。
您可以使用 std::unique_ptr
而不是 std::auto_ptr
如果您复制了 auto_ptr
,则必须 std::move
unique_ptr
。
尝试使用 g++
编译器 -std=c++11
,我得到了很多
warning: ‘auto_ptr’ is deprecated (declared at
/usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations]
我应该用什么代替 auto_ptr
?请提供信息 link 或完整的答案。
"What should I use instead of
auto_ptr
?"
最接近std::auto_ptr<>
行为的class是std::unique_ptr<>
。
您可以使用 std::unique_ptr
而不是 std::auto_ptr
如果您复制了 auto_ptr
,则必须 std::move
unique_ptr
。