OLD | NEW |
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_MEMORY_REF_COUNTED_H_ | 5 #ifndef BASE_MEMORY_REF_COUNTED_H_ |
6 #define BASE_MEMORY_REF_COUNTED_H_ | 6 #define BASE_MEMORY_REF_COUNTED_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 |
8 #include <cassert> | 10 #include <cassert> |
9 #include <iosfwd> | 11 #include <iosfwd> |
10 #include <type_traits> | 12 #include <type_traits> |
11 | 13 |
12 #include "base/atomic_ref_count.h" | 14 #include "base/atomic_ref_count.h" |
13 #include "base/base_export.h" | 15 #include "base/base_export.h" |
14 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
15 #include "base/macros.h" | 17 #include "base/macros.h" |
16 #ifndef NDEBUG | 18 #ifndef NDEBUG |
17 #include "base/logging.h" | 19 #include "base/logging.h" |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 template <typename T, typename U> | 436 template <typename T, typename U> |
435 bool operator==(const scoped_refptr<T>& lhs, const U* rhs) { | 437 bool operator==(const scoped_refptr<T>& lhs, const U* rhs) { |
436 return lhs.get() == rhs; | 438 return lhs.get() == rhs; |
437 } | 439 } |
438 | 440 |
439 template <typename T, typename U> | 441 template <typename T, typename U> |
440 bool operator==(const T* lhs, const scoped_refptr<U>& rhs) { | 442 bool operator==(const T* lhs, const scoped_refptr<U>& rhs) { |
441 return lhs == rhs.get(); | 443 return lhs == rhs.get(); |
442 } | 444 } |
443 | 445 |
| 446 template <typename T> |
| 447 bool operator==(const scoped_refptr<T>& lhs, std::nullptr_t null) { |
| 448 return !static_cast<bool>(lhs); |
| 449 } |
| 450 |
| 451 template <typename T> |
| 452 bool operator==(std::nullptr_t null, const scoped_refptr<T>& rhs) { |
| 453 return !static_cast<bool>(rhs); |
| 454 } |
| 455 |
444 template <typename T, typename U> | 456 template <typename T, typename U> |
445 bool operator!=(const scoped_refptr<T>& lhs, const U* rhs) { | 457 bool operator!=(const scoped_refptr<T>& lhs, const U* rhs) { |
446 return !operator==(lhs, rhs); | 458 return !operator==(lhs, rhs); |
447 } | 459 } |
448 | 460 |
449 template <typename T, typename U> | 461 template <typename T, typename U> |
450 bool operator!=(const T* lhs, const scoped_refptr<U>& rhs) { | 462 bool operator!=(const T* lhs, const scoped_refptr<U>& rhs) { |
451 return !operator==(lhs, rhs); | 463 return !operator==(lhs, rhs); |
452 } | 464 } |
453 | 465 |
454 template <typename T> | 466 template <typename T> |
| 467 bool operator!=(const scoped_refptr<T>& lhs, std::nullptr_t null) { |
| 468 return !operator==(lhs, null); |
| 469 } |
| 470 |
| 471 template <typename T> |
| 472 bool operator!=(std::nullptr_t null, const scoped_refptr<T>& rhs) { |
| 473 return !operator==(null, rhs); |
| 474 } |
| 475 |
| 476 template <typename T> |
455 std::ostream& operator<<(std::ostream& out, const scoped_refptr<T>& p) { | 477 std::ostream& operator<<(std::ostream& out, const scoped_refptr<T>& p) { |
456 return out << p.get(); | 478 return out << p.get(); |
457 } | 479 } |
458 | 480 |
459 #endif // BASE_MEMORY_REF_COUNTED_H_ | 481 #endif // BASE_MEMORY_REF_COUNTED_H_ |
OLD | NEW |