Chromium Code Reviews| Index: base/memory/ref_counted.h |
| diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h |
| index 0c0e0afd770f4bb3f71d222b098d200c4e3688d4..69e8f485b9d83e08dd5ebc030e4f92d934a09077 100644 |
| --- a/base/memory/ref_counted.h |
| +++ b/base/memory/ref_counted.h |
| @@ -5,6 +5,8 @@ |
| #ifndef BASE_MEMORY_REF_COUNTED_H_ |
| #define BASE_MEMORY_REF_COUNTED_H_ |
| +#include <stddef.h> |
| + |
| #include <cassert> |
| #include <iosfwd> |
| #include <type_traits> |
| @@ -441,6 +443,16 @@ bool operator==(const T* lhs, const scoped_refptr<U>& rhs) { |
| return lhs == rhs.get(); |
| } |
| +template <typename T> |
| +bool operator==(const scoped_refptr<T>& lhs, std::nullptr_t null) { |
| + return lhs.get() == null; |
|
danakj
2016/05/17 23:14:08
can you implement this in terms of already existin
Rob Percival
2016/05/18 01:17:01
Done.
|
| +} |
| + |
| +template <typename T> |
| +bool operator==(std::nullptr_t null, const scoped_refptr<T>& rhs) { |
| + return null == rhs.get(); |
|
danakj
2016/05/17 23:14:08
ditto
Rob Percival
2016/05/18 01:17:01
Done.
|
| +} |
| + |
| template <typename T, typename U> |
| bool operator!=(const scoped_refptr<T>& lhs, const U* rhs) { |
| return !operator==(lhs, rhs); |
| @@ -452,6 +464,16 @@ bool operator!=(const T* lhs, const scoped_refptr<U>& rhs) { |
| } |
| template <typename T> |
| +bool operator!=(const scoped_refptr<T>& lhs, std::nullptr_t null) { |
| + return !operator==(lhs, null); |
| +} |
| + |
| +template <typename T> |
| +bool operator!=(std::nullptr_t null, const scoped_refptr<T>& rhs) { |
| + return !operator==(null, rhs); |
| +} |
| + |
| +template <typename T> |
| std::ostream& operator<<(std::ostream& out, const scoped_refptr<T>& p) { |
| return out << p.get(); |
| } |