Rename embedded smart pointer in SwigValueWrapper in order to avoid conflicts with the template type
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11038 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f94edcd855
commit
c577ac1a31
1 changed files with 6 additions and 6 deletions
12
Lib/swig.swg
12
Lib/swig.swg
|
|
@ -634,7 +634,7 @@ 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 Pointer nested class is
|
||||
* With regards to the implementation, the private SwigMovePointer nested class is
|
||||
* a simple smart pointer with move semantics, much like std::auto_ptr.
|
||||
*
|
||||
* This wrapping technique was suggested by William Fulton and is henceforth
|
||||
|
|
@ -646,17 +646,17 @@ namespace std {
|
|||
#ifdef __cplusplus
|
||||
/* SwigValueWrapper is described in swig.swg */
|
||||
template<typename T> class SwigValueWrapper {
|
||||
struct Pointer {
|
||||
struct SwigMovePointer {
|
||||
T *ptr;
|
||||
Pointer(T *p) : ptr(p) { }
|
||||
~Pointer() { delete ptr; }
|
||||
Pointer& operator=(Pointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
|
||||
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; }
|
||||
} pointer;
|
||||
SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
|
||||
SwigValueWrapper(const SwigValueWrapper<T>& rhs);
|
||||
public:
|
||||
SwigValueWrapper() : pointer(0) { }
|
||||
SwigValueWrapper& operator=(const T& t) { Pointer tmp(new T(t)); pointer = tmp; return *this; }
|
||||
SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
|
||||
operator T&() const { return *pointer.ptr; }
|
||||
T *operator&() { return pointer.ptr; }
|
||||
};%}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue