Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(750)

Side by Side Diff: base/mac/scoped_nsobject.h

Issue 2485463002: Fix scoped_nsobject move constructor. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/mac/scoped_nsobject_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_MAC_SCOPED_NSOBJECT_H_ 5 #ifndef BASE_MAC_SCOPED_NSOBJECT_H_
6 #define BASE_MAC_SCOPED_NSOBJECT_H_ 6 #define BASE_MAC_SCOPED_NSOBJECT_H_
7 7
8 #include <type_traits> 8 #include <type_traits>
9 9
10 // Include NSObject.h directly because Foundation.h pulls in many dependencies. 10 // Include NSObject.h directly because Foundation.h pulls in many dependencies.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 #endif 95 #endif
96 96
97 scoped_nsprotocol(const scoped_nsprotocol<NST>& that) 97 scoped_nsprotocol(const scoped_nsprotocol<NST>& that)
98 : ScopedTypeRef<NST, Traits>(that) {} 98 : ScopedTypeRef<NST, Traits>(that) {}
99 99
100 template <typename NSR> 100 template <typename NSR>
101 explicit scoped_nsprotocol(const scoped_nsprotocol<NSR>& that_as_subclass) 101 explicit scoped_nsprotocol(const scoped_nsprotocol<NSR>& that_as_subclass)
102 : ScopedTypeRef<NST, Traits>(that_as_subclass) {} 102 : ScopedTypeRef<NST, Traits>(that_as_subclass) {}
103 103
104 scoped_nsprotocol(scoped_nsprotocol<NST>&& that) 104 scoped_nsprotocol(scoped_nsprotocol<NST>&& that)
105 : ScopedTypeRef<NST, Traits>(that) {} 105 : ScopedTypeRef<NST, Traits>(std::move(that)) {}
106 106
107 scoped_nsprotocol& operator=(const scoped_nsprotocol<NST>& that) { 107 scoped_nsprotocol& operator=(const scoped_nsprotocol<NST>& that) {
108 ScopedTypeRef<NST, Traits>::operator=(that); 108 ScopedTypeRef<NST, Traits>::operator=(that);
109 return *this; 109 return *this;
110 } 110 }
111 111
112 #if !defined(__has_feature) || !__has_feature(objc_arc) 112 #if !defined(__has_feature) || !__has_feature(objc_arc)
113 void reset(NST object = Traits::InvalidValue(), 113 void reset(NST object = Traits::InvalidValue(),
114 base::scoped_policy::OwnershipPolicy policy = 114 base::scoped_policy::OwnershipPolicy policy =
115 base::scoped_policy::ASSUME) { 115 base::scoped_policy::ASSUME) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 #endif 159 #endif
160 160
161 scoped_nsobject(const scoped_nsobject<NST>& that) 161 scoped_nsobject(const scoped_nsobject<NST>& that)
162 : scoped_nsprotocol<NST*>(that) {} 162 : scoped_nsprotocol<NST*>(that) {}
163 163
164 template <typename NSR> 164 template <typename NSR>
165 explicit scoped_nsobject(const scoped_nsobject<NSR>& that_as_subclass) 165 explicit scoped_nsobject(const scoped_nsobject<NSR>& that_as_subclass)
166 : scoped_nsprotocol<NST*>(that_as_subclass) {} 166 : scoped_nsprotocol<NST*>(that_as_subclass) {}
167 167
168 scoped_nsobject(scoped_nsobject<NST>&& that) 168 scoped_nsobject(scoped_nsobject<NST>&& that)
169 : scoped_nsprotocol<NST*>(that) {} 169 : scoped_nsprotocol<NST*>(std::move(that)) {}
170 170
171 scoped_nsobject& operator=(const scoped_nsobject<NST>& that) { 171 scoped_nsobject& operator=(const scoped_nsobject<NST>& that) {
172 scoped_nsprotocol<NST*>::operator=(that); 172 scoped_nsprotocol<NST*>::operator=(that);
173 return *this; 173 return *this;
174 } 174 }
175 175
176 #if !defined(__has_feature) || !__has_feature(objc_arc) 176 #if !defined(__has_feature) || !__has_feature(objc_arc)
177 void reset(NST* object = Traits::InvalidValue(), 177 void reset(NST* object = Traits::InvalidValue(),
178 base::scoped_policy::OwnershipPolicy policy = 178 base::scoped_policy::OwnershipPolicy policy =
179 base::scoped_policy::ASSUME) { 179 base::scoped_policy::ASSUME) {
(...skipping 27 matching lines...) Expand all
207 : scoped_nsprotocol<id>(object) {} 207 : scoped_nsprotocol<id>(object) {}
208 #endif 208 #endif
209 209
210 scoped_nsobject(const scoped_nsobject<id>& that) 210 scoped_nsobject(const scoped_nsobject<id>& that)
211 : scoped_nsprotocol<id>(that) {} 211 : scoped_nsprotocol<id>(that) {}
212 212
213 template <typename NSR> 213 template <typename NSR>
214 explicit scoped_nsobject(const scoped_nsobject<NSR>& that_as_subclass) 214 explicit scoped_nsobject(const scoped_nsobject<NSR>& that_as_subclass)
215 : scoped_nsprotocol<id>(that_as_subclass) {} 215 : scoped_nsprotocol<id>(that_as_subclass) {}
216 216
217 scoped_nsobject(scoped_nsobject<id>&& that) : scoped_nsprotocol<id>(that) {} 217 scoped_nsobject(scoped_nsobject<id>&& that)
218 : scoped_nsprotocol<id>(std::move(that)) {}
218 219
219 scoped_nsobject& operator=(const scoped_nsobject<id>& that) { 220 scoped_nsobject& operator=(const scoped_nsobject<id>& that) {
220 scoped_nsprotocol<id>::operator=(that); 221 scoped_nsprotocol<id>::operator=(that);
221 return *this; 222 return *this;
222 } 223 }
223 224
224 #if !defined(__has_feature) || !__has_feature(objc_arc) 225 #if !defined(__has_feature) || !__has_feature(objc_arc)
225 void reset(id object = Traits::InvalidValue(), 226 void reset(id object = Traits::InvalidValue(),
226 base::scoped_policy::OwnershipPolicy policy = 227 base::scoped_policy::OwnershipPolicy policy =
227 base::scoped_policy::ASSUME) { 228 base::scoped_policy::ASSUME) {
228 scoped_nsprotocol<id>::reset(object, policy); 229 scoped_nsprotocol<id>::reset(object, policy);
229 } 230 }
230 #else 231 #else
231 void reset(id object = Traits::InvalidValue()) { 232 void reset(id object = Traits::InvalidValue()) {
232 scoped_nsprotocol<id>::reset(object); 233 scoped_nsprotocol<id>::reset(object);
233 } 234 }
234 #endif 235 #endif
235 }; 236 };
236 237
237 } // namespace base 238 } // namespace base
238 239
239 #endif // BASE_MAC_SCOPED_NSOBJECT_H_ 240 #endif // BASE_MAC_SCOPED_NSOBJECT_H_
OLDNEW
« no previous file with comments | « no previous file | base/mac/scoped_nsobject_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698