Adds equality operators for comparing scoped_refptr with nullptr.

Review-Url: https://codereview.chromium.org/1993433002
Cr-Commit-Position: refs/heads/master@{#394620}


CrOS-Libchrome-Original-Commit: 3d1a0004b6d793eb91c438b6058dfbbcf44f4dd7
diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h
index 01da9b1..5b866d1 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>
@@ -422,6 +424,16 @@
   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);
@@ -433,6 +445,16 @@
 }
 
 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();
 }