SwigValueWrapper fixes
- memory leak fix - default arguments for parameters that are classes bug fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4971 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ad7cd027c0
commit
02f3bfdbf4
1 changed files with 9 additions and 6 deletions
|
|
@ -311,12 +311,15 @@ namespace std {
|
|||
template<class T> class SwigValueWrapper {
|
||||
T *tt;
|
||||
public:
|
||||
inline SwigValueWrapper() : tt(0) { }
|
||||
inline SwigValueWrapper(const T& t) : tt(new T(t)) { }
|
||||
inline ~SwigValueWrapper() { if (tt) delete tt; }
|
||||
inline SwigValueWrapper& operator=(const T& t) { tt = new T(t); return *this; }
|
||||
inline operator T&() const { return *tt; }
|
||||
inline T *operator&() { return tt; }
|
||||
SwigValueWrapper() : tt(0) { }
|
||||
SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { }
|
||||
SwigValueWrapper(const T& t) : tt(new T(t)) { }
|
||||
~SwigValueWrapper() { delete tt; }
|
||||
SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; }
|
||||
operator T&() const { return *tt; }
|
||||
T *operator&() { return tt; }
|
||||
private:
|
||||
SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
|
||||
};
|
||||
#endif
|
||||
%}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue