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)
llvm-svn: 157546

llvm/include/llvm/ADT/IntrusiveRefCntPtr.h

index 947ccc4..37018d9 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