[llvm-commits] [llvm] r157546 - /llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h

Benjamin Kramer benny.kra at googlemail.com
Sun May 27 13:46:04 PDT 2012


Author: d0k
Date: Sun May 27 15:46:04 2012
New Revision: 157546

URL: http://llvm.org/viewvc/llvm-project?rev=157546&view=rev
Log:
IntrusiveRefCntPtr: Use the same pattern as the other operator= overloads when using rvalue refs.

Modified:
    llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h

Modified: llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h?rev=157546&r1=157545&r2=157546&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h (original)
+++ llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h Sun May 27 15:46:04 2012
@@ -23,6 +23,7 @@
 
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
+#include <memory>
 
 namespace llvm {
 
@@ -146,15 +147,13 @@
 
 #if LLVM_USE_RVALUE_REFERENCES
     IntrusiveRefCntPtr& operator=(IntrusiveRefCntPtr&& S) {
-      Obj = S.Obj;
-      S.Obj = 0;
+      this_type(std::move(S)).swap(*this);
       return *this;
     }
 
     template <class X>
     IntrusiveRefCntPtr& operator=(IntrusiveRefCntPtr<X>&& S) {
-      Obj = S.getPtr();
-      S.Obj = 0;
+      this_type(std::move(S)).swap(*this);
       return *this;
     }
 #endif





More information about the llvm-commits mailing list