OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkRefCnt_DEFINED | 8 #ifndef SkRefCnt_DEFINED |
9 #define SkRefCnt_DEFINED | 9 #define SkRefCnt_DEFINED |
10 | 10 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 this->reset(that.release()); | 288 this->reset(that.release()); |
289 return *this; | 289 return *this; |
290 } | 290 } |
291 | 291 |
292 bool operator==(std::nullptr_t) const { return this->get() == nullptr; } | 292 bool operator==(std::nullptr_t) const { return this->get() == nullptr; } |
293 bool operator!=(std::nullptr_t) const { return this->get() != nullptr; } | 293 bool operator!=(std::nullptr_t) const { return this->get() != nullptr; } |
294 | 294 |
295 bool operator==(const sk_sp<T>& that) const { return this->get() == that.get
(); } | 295 bool operator==(const sk_sp<T>& that) const { return this->get() == that.get
(); } |
296 bool operator!=(const sk_sp<T>& that) const { return this->get() != that.get
(); } | 296 bool operator!=(const sk_sp<T>& that) const { return this->get() != that.get
(); } |
297 | 297 |
298 explicit operator bool() const { return this->get() != nullptr; } | 298 // MSVC 2013 does not work correctly with explicit operator bool. |
| 299 // https://chromium-cpp.appspot.com/#core-blacklist |
| 300 //explicit operator bool() const { return this->get() != nullptr; } |
| 301 |
| 302 bool operator!() const { return this->get() == nullptr; } |
299 | 303 |
300 T* get() const { return fPtr; } | 304 T* get() const { return fPtr; } |
301 T* operator->() const { return fPtr; } | 305 T* operator->() const { return fPtr; } |
302 | 306 |
303 /** | 307 /** |
304 * Adopt the new bare pointer, and call unref() on any previously held obje
ct (if not null). | 308 * Adopt the new bare pointer, and call unref() on any previously held obje
ct (if not null). |
305 * No call to ref() will be made. | 309 * No call to ref() will be made. |
306 */ | 310 */ |
307 void reset(T* ptr = nullptr) { | 311 void reset(T* ptr = nullptr) { |
308 if (fPtr != ptr) { | 312 if (fPtr != ptr) { |
(...skipping 11 matching lines...) Expand all Loading... |
320 T* ptr = fPtr; | 324 T* ptr = fPtr; |
321 fPtr = nullptr; | 325 fPtr = nullptr; |
322 return ptr; | 326 return ptr; |
323 } | 327 } |
324 | 328 |
325 private: | 329 private: |
326 T* fPtr; | 330 T* fPtr; |
327 }; | 331 }; |
328 | 332 |
329 #endif | 333 #endif |
OLD | NEW |