[llvm] r210100 - Add operator== and operator!= to compare with nullptr.

Rafael Espindola rafael.espindola at gmail.com
Tue Jun 3 06:26:18 PDT 2014


Author: rafael
Date: Tue Jun  3 08:26:18 2014
New Revision: 210100

URL: http://llvm.org/viewvc/llvm-project?rev=210100&view=rev
Log:
Add operator== and operator!= to compare with nullptr.

Modified:
    llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h

Modified: llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h?rev=210100&r1=210099&r2=210100&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h (original)
+++ llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h Tue Jun  3 08:26:18 2014
@@ -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
 //===----------------------------------------------------------------------===//





More information about the llvm-commits mailing list