diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-05-31 22:25:25 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-05-31 22:25:25 +0000 |
commit | 91a8ad71aa5d08e37a8a4ed364d0dae720d8ea7c (patch) | |
tree | 17242791933cc538f471a1e1a5ab49108b4ecd52 | |
parent | a835f00702328df8da968d27b2d5849078ed77e6 (diff) | |
download | external_llvm-91a8ad71aa5d08e37a8a4ed364d0dae720d8ea7c.zip external_llvm-91a8ad71aa5d08e37a8a4ed364d0dae720d8ea7c.tar.gz external_llvm-91a8ad71aa5d08e37a8a4ed364d0dae720d8ea7c.tar.bz2 |
IntrusiveRefCntPtr: Simplify operator= as suggested by Richard Smith.
This way the constructors do all the hard work. No intended functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157773 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/ADT/IntrusiveRefCntPtr.h | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/include/llvm/ADT/IntrusiveRefCntPtr.h b/include/llvm/ADT/IntrusiveRefCntPtr.h index 37018d9..0c02a8f 100644 --- a/include/llvm/ADT/IntrusiveRefCntPtr.h +++ b/include/llvm/ADT/IntrusiveRefCntPtr.h @@ -140,32 +140,8 @@ namespace llvm { 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 @@ namespace llvm { 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> |