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)
llvm-svn: 210100

llvm/include/llvm/ADT/IntrusiveRefCntPtr.h

index 295c963..846ae39 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
 //===----------------------------------------------------------------------===//