IntrusiveRefCntPtr: Use the same pattern as the other operator= overloads when using...
authorBenjamin Kramer <benny.kra@googlemail.com>
Sun, 27 May 2012 20:46:04 +0000 (20:46 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sun, 27 May 2012 20:46:04 +0000 (20:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157546 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/IntrusiveRefCntPtr.h

index 947ccc46a5236b75d701f0b2ccd5e5ec0697c0bf..37018d95e604fc5fa6ff3019c9e45c4f57f51887 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
+#include <memory>
 
 namespace llvm {
 
@@ -146,15 +147,13 @@ namespace llvm {
 
 #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