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:
parent
5c1c69d140
commit
d6ef118219
1 changed files with 20 additions and 2 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue