c++11auto-ptr

Warning linking libxml++-2.6 (c++11 obsoltes std::auto_ptr). Shall I just ignore it?


Using gcc with -std=c++11

pkg-config libxml++-2.6 --modversion

2.40.1

get lots of warnings like this: /usr/include/libxml++-2.6/libxml++/parsers/saxparser.h:224:8: warning: 'template class std::auto_ptr' is deprecated [-Wdeprecated-declarations]

  1. I may follow the recommendation and disable this warning but I may miss other warnings in future.
  2. I may try latest libxml++ version 2.91; despite huge minor(lol) version difference it's at most one month younger; I'll build this on older machines where libxml++ will probably be older.

I'll ignore this warning. Would anybody do otherwise ?


Solution

  • You should be safe ignoring the std::auto_ptr warning. Prior to C++11, auto_ptr was a common way to manage memory, because it takes ownership of a pointer. Post C++11 it's recommended to use the new smart pointers that are part of STL (ie std::unique_ptr, std::shared_ptr).

    This question has a good discussion on std::auto_ptr and issues that led to it being deprecated. I wouldn't write new code using it, but existing code using auto_ptr should be safe (assuming there aren't bugs to begin with which may or may not be valid).