Add operator== and operator!= to compare with nullptr.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 3 Jun 2014 13:26:18 +0000 (13:26 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 3 Jun 2014 13:26:18 +0000 (13:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210100 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/IntrusiveRefCntPtr.h

index 295c96315a5fbfb5141bf692982d2708a187799b..846ae3975dc5b8f0242918ce662e98fe7893bc4e 100644 (file)
@@ -241,6 +241,26 @@ public:
     return A != B.getPtr();
   }
 
+  template <class T>
+  bool operator==(std::nullptr_t A, const IntrusiveRefCntPtr<T> &B) {
+    return !B;
+  }
+
+  template <class T>
+  bool operator==(const IntrusiveRefCntPtr<T> &A, std::nullptr_t B) {
+    return !A;
+  }
+
+  template <class T>
+  bool operator!=(std::nullptr_t A, const IntrusiveRefCntPtr<T> &B) {
+    return !(A == B);
+  }
+
+  template <class T>
+  bool operator!=(const IntrusiveRefCntPtr<T> &A, std::nullptr_t B) {
+    return !(A == B);
+  }
+
 //===----------------------------------------------------------------------===//
 // LLVM-style downcasting support for IntrusiveRefCntPtr objects
 //===----------------------------------------------------------------------===//