diff options
author | Murray Cumming <murrayc@murrayc.com> | 2015-07-28 10:31:10 +0200 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2015-08-01 21:41:48 +0200 |
commit | a427c8fb49a38912f8a7b6f1ffbf4aa9e2fb16d3 (patch) | |
tree | 49b85ae4b9c121a46195b84f54cb9490470dc10b /glib/glibmm/refptr.h | |
parent | 88d59eff69d399c6f557f8c2be7599e31740b841 (diff) | |
download | glibmm-a427c8fb49a38912f8a7b6f1ffbf4aa9e2fb16d3.tar.gz |
RefPtr: move assignment operator: Use swap().
This is not actually less efficient - the code is inline anyway.
Bug #752876
Diffstat (limited to 'glib/glibmm/refptr.h')
-rw-r--r-- | glib/glibmm/refptr.h | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/glib/glibmm/refptr.h b/glib/glibmm/refptr.h index 4c1913e3..5e213849 100644 --- a/glib/glibmm/refptr.h +++ b/glib/glibmm/refptr.h @@ -20,6 +20,7 @@ */ #include <glibmmconfig.h> +#include <utility> namespace Glib { @@ -323,17 +324,10 @@ RefPtr<T_CppObject>& RefPtr<T_CppObject>::operator=(const RefPtr& src) template <class T_CppObject> inline RefPtr<T_CppObject>& RefPtr<T_CppObject>::operator=(RefPtr&& src) { - if (pCppObject_) - pCppObject_->unreference(); - - pCppObject_ = src.pCppObject_; + RefPtr<T_CppObject> temp (std::move(src)); + this->swap(temp); src.pCppObject_ = nullptr; - //This should work instead, but seems less efficient: - //RefPtr<T_CppObject> temp (src); - //this->swap(temp); - //src.pCppObject_ = nullptr; - return *this; } |