llvm.org GIT mirror llvm / 91a8ad7
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 Benjamin Kramer 8 years ago
1 changed file(s) with 2 addition(s) and 30 deletion(s). Raw diff Collapse all Expand all
139139 retain();
140140 }
141141
142 IntrusiveRefCntPtr& operator=(const IntrusiveRefCntPtr& S) {
143 replace(S.getPtr());
144 return *this;
145 }
146
147 #if LLVM_USE_RVALUE_REFERENCES
148 IntrusiveRefCntPtr& operator=(IntrusiveRefCntPtr&& S) {
149 this_type(std::move(S)).swap(*this);
150 return *this;
151 }
152
153 template
154 IntrusiveRefCntPtr& operator=(IntrusiveRefCntPtr&& S) {
155 this_type(std::move(S)).swap(*this);
156 return *this;
157 }
158 #endif
159
160 template
161 IntrusiveRefCntPtr& operator=(const IntrusiveRefCntPtr& S) {
162 replace(S.getPtr());
163 return *this;
164 }
165
166 IntrusiveRefCntPtr& operator=(T * S) {
167 replace(S);
142 IntrusiveRefCntPtr& operator=(IntrusiveRefCntPtr S) {
143 swap(S);
168144 return *this;
169145 }
170146
199175 private:
200176 void retain() { if (Obj) IntrusiveRefCntPtrInfo::retain(Obj); }
201177 void release() { if (Obj) IntrusiveRefCntPtrInfo::release(Obj); }
202
203 void replace(T* S) {
204 this_type(S).swap(*this);
205 }
206178 };
207179
208180 template