std::auto_ptr replacement for testing with C++17 and later

Keep suppressing deprecated warnings for C++11 and C++14
This commit is contained in:
William S Fulton 2019-06-14 18:44:05 +01:00
commit d6ef118219

View file

@ -18,11 +18,29 @@
%auto_ptr(Klass)
%inline %{
%{
#if __cplusplus < 201703L
#include <memory>
#else
// Simple std::auto_ptr implementation for testing after its removal in C++17
namespace std {
template <class T> class auto_ptr {
T *ptr;
public:
auto_ptr(T *ptr = 0) : ptr(ptr) {}
auto_ptr(auto_ptr&& a) : ptr(a.ptr) { a.ptr = 0;}
~auto_ptr() { delete ptr; }
T *release() { T *p = ptr; ptr = 0; return p; }
auto_ptr& operator=(auto_ptr&& a) { if (&a != this) { delete ptr; ptr = a.ptr; a.ptr = 0; } return *this; }
};
}
#endif
#include <string>
#include "swig_examples_lock.h"
%}
%inline %{
class Klass {
public: