From 4dd285fad736c014224ef2ad25b85e17f3dce1f9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 16 Jun 2022 07:47:44 +0100 Subject: [PATCH] Cosmetic rename SwigMovePointer -> SwigSmartPointer This smart pointer doesn't really offer move semantics as is commonly understood in C++11, so rename accordingly. --- Lib/swig.swg | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Lib/swig.swg b/Lib/swig.swg index 9978ae9b7..f6ba3a69f 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -653,8 +653,8 @@ namespace std { * arg1 = Vector(1,2,3); // Assignment from a value * * The class offers a strong guarantee of exception safety. - * With regards to the implementation, the private SwigMovePointer nested class is - * a simple smart pointer with move semantics, much like std::auto_ptr. + * With regards to the implementation, the private SwigSmartPointer nested class is + * a simple smart pointer providing exception safety, much like std::auto_ptr. * * This wrapping technique was suggested by William Fulton and is henceforth * known as the "Fulton Transform" :-). @@ -666,19 +666,19 @@ namespace std { #include /* SwigValueWrapper is described in swig.swg */ template class SwigValueWrapper { - struct SwigMovePointer { + struct SwigSmartPointer { T *ptr; - SwigMovePointer(T *p) : ptr(p) { } - ~SwigMovePointer() { delete ptr; } - SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } + SwigSmartPointer(T *p) : ptr(p) { } + ~SwigSmartPointer() { delete ptr; } + SwigSmartPointer& operator=(SwigSmartPointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } } pointer; SwigValueWrapper& operator=(const SwigValueWrapper& rhs); SwigValueWrapper(const SwigValueWrapper& rhs); public: SwigValueWrapper() : pointer(0) { } - SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; } + SwigValueWrapper& operator=(const T& t) { SwigSmartPointer tmp(new T(t)); pointer = tmp; return *this; } #if __cplusplus >= 201103L - SwigValueWrapper& operator=(T&& t) { SwigMovePointer tmp(new T(std::move(t))); pointer = tmp; return *this; } + SwigValueWrapper& operator=(T&& t) { SwigSmartPointer tmp(new T(std::move(t))); pointer = tmp; return *this; } #endif operator T&() const { return *pointer.ptr; } T *operator&() { return pointer.ptr; }