Have shared project library that has to be compiled with various compilers C++17 C++03 etc. So just using the better unique_ptr or the less than perfect auto_ptr as appropriate is not ideal if the code is to be kept common.
Have look at the #ifdef type solution but it gets messy. Plus making edits to well tried and tested coded is not a particular attractive idea!
Anyone know of a form, fit and function drop in replacement for auto_ptr?
There are Boost.Move and Boost Smart Pointer.
std::unique_ptrandstd::auto_ptrmay be replaced byboost::movelib::unique_ptr.std::shared_ptrandstd::weak_ptrbyboost::shared_ptrandboost::weak_ptr.And, you can be more expressive with
boost::scoped_ptrwhen there is no intent to transfer ownership.