diff options
author | Murray Cumming <murrayc@murrayc.com> | 2015-07-18 22:47:56 +0200 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2015-07-18 22:52:28 +0200 |
commit | 10898bc89ef57b2447b559af7e4e925739839f7d (patch) | |
tree | db1e4d5f3ac25abeccd742e12049ffe109c5f528 /glib/glibmm/refptr.h | |
parent | 9097cd499b3518219ac3a04edf7349012b70a618 (diff) | |
download | glibmm-10898bc89ef57b2447b559af7e4e925739839f7d.tar.gz |
RefPtr: Add move constructor and move assignment operator.
Diffstat (limited to 'glib/glibmm/refptr.h')
-rw-r--r-- | glib/glibmm/refptr.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/glib/glibmm/refptr.h b/glib/glibmm/refptr.h index 79d05ce4..fd57b361 100644 --- a/glib/glibmm/refptr.h +++ b/glib/glibmm/refptr.h @@ -68,6 +68,10 @@ public: */ inline RefPtr(const RefPtr& src); + /** Move constructor + */ + inline RefPtr(RefPtr&& src); + /** Copy constructor (from different, but castable type). * * Increments the reference count. @@ -85,6 +89,9 @@ public: /// Copy from another RefPtr: inline RefPtr& operator=(const RefPtr& src); + /// Move assignment operator: + inline RefPtr& operator=(RefPtr&& src); + /** Copy from different, but castable type). * * Increments the reference count. @@ -223,6 +230,14 @@ RefPtr<T_CppObject>::RefPtr(const RefPtr& src) pCppObject_->reference(); } +template <class T_CppObject> inline +RefPtr<T_CppObject>::RefPtr(RefPtr&& src) +: + pCppObject_ (src.pCppObject_) +{ + src.pCppObject_ = nullptr; +} + // The templated ctor allows copy construction from any object that's // castable. Thus, it does downcasts: // base_ref = derived_ref @@ -280,6 +295,14 @@ RefPtr<T_CppObject>& RefPtr<T_CppObject>::operator=(const RefPtr& src) return *this; } +template <class T_CppObject> inline +RefPtr<T_CppObject>& RefPtr<T_CppObject>::operator=(RefPtr&& src) +{ + pCppObject_ = src.pCppObject_; + src.pCppObject_ = nullptr; + return *this; +} + template <class T_CppObject> template <class T_CastFrom> inline |