Index: base/memory/ref_counted.h |
diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h |
index 0c0e0afd770f4bb3f71d222b098d200c4e3688d4..dfe66d6e0351ea94f915eecaca4b3d9b8560542f 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 !static_cast<bool>(lhs); |
+} |
+ |
+template <typename T> |
+bool operator==(std::nullptr_t null, const scoped_refptr<T>& rhs) { |
+ return !static_cast<bool>(rhs); |
+} |
+ |
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(); |
} |