diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2019-06-14 18:44:05 +0100 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2019-06-27 07:40:49 +0100 |
commit | d6ef11821944d697cc946f1c5d05999285785f5d (patch) | |
tree | 802adb4be0187a51123f20e26340633827b0cba3 | |
parent | 5c1c69d14040bc5e04d4682f43ceeb45af93e1ca (diff) | |
download | swig-d6ef11821944d697cc946f1c5d05999285785f5d.tar.gz |
std::auto_ptr replacement for testing with C++17 and later
Keep suppressing deprecated warnings for C++11 and C++14
-rw-r--r-- | Examples/test-suite/li_std_auto_ptr.i | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/Examples/test-suite/li_std_auto_ptr.i b/Examples/test-suite/li_std_auto_ptr.i index 7693a3118..5bde387a3 100644 --- a/Examples/test-suite/li_std_auto_ptr.i +++ b/Examples/test-suite/li_std_auto_ptr.i @@ -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: |