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

Benjamin Kramer benny.kra at googlemail.com
Thu May 31 15:25:25 PDT 2012


Author: d0k
Date: Thu May 31 17:25:25 2012
New Revision: 157773

URL: http://llvm.org/viewvc/llvm-project?rev=157773&view=rev
Log:
IntrusiveRefCntPtr: Simplify operator= as suggested by Richard Smith.

This way the constructors do all the hard work. No intended functionality change.

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=157773&r1=157772&r2=157773&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h (original)
+++ llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h Thu May 31 17:25:25 2012
@@ -140,32 +140,8 @@
       retain();
     }
 
-    IntrusiveRefCntPtr& operator=(const IntrusiveRefCntPtr& S) {
-      replace(S.getPtr());
-      return *this;
-    }
-
-#if LLVM_USE_RVALUE_REFERENCES
-    IntrusiveRefCntPtr& operator=(IntrusiveRefCntPtr&& S) {
-      this_type(std::move(S)).swap(*this);
-      return *this;
-    }
-
-    template <class X>
-    IntrusiveRefCntPtr& operator=(IntrusiveRefCntPtr<X>&& S) {
-      this_type(std::move(S)).swap(*this);
-      return *this;
-    }
-#endif
-
-    template <class X>
-    IntrusiveRefCntPtr& operator=(const IntrusiveRefCntPtr<X>& S) {
-      replace(S.getPtr());
-      return *this;
-    }
-
-    IntrusiveRefCntPtr& operator=(T * S) {
-      replace(S);
+    IntrusiveRefCntPtr& operator=(IntrusiveRefCntPtr S) {
+      swap(S);
       return *this;
     }
 
@@ -200,10 +176,6 @@
   private:
     void retain() { if (Obj) IntrusiveRefCntPtrInfo<T>::retain(Obj); }
     void release() { if (Obj) IntrusiveRefCntPtrInfo<T>::release(Obj); }
-
-    void replace(T* S) {
-      this_type(S).swap(*this);
-    }
   };
 
   template<class T, class U>





More information about the llvm-commits mailing list