From e9b2cf3456e2ecc04e63f9ea03cfc47ffbb12614 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 3 Jun 2014 13:26:18 +0000 Subject: [PATCH] Add operator== and operator!= to compare with nullptr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210100 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/IntrusiveRefCntPtr.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/llvm/ADT/IntrusiveRefCntPtr.h b/include/llvm/ADT/IntrusiveRefCntPtr.h index 295c96315a5..846ae3975dc 100644 --- a/include/llvm/ADT/IntrusiveRefCntPtr.h +++ b/include/llvm/ADT/IntrusiveRefCntPtr.h @@ -241,6 +241,26 @@ public: return A != B.getPtr(); } + template + bool operator==(std::nullptr_t A, const IntrusiveRefCntPtr &B) { + return !B; + } + + template + bool operator==(const IntrusiveRefCntPtr &A, std::nullptr_t B) { + return !A; + } + + template + bool operator!=(std::nullptr_t A, const IntrusiveRefCntPtr &B) { + return !(A == B); + } + + template + bool operator!=(const IntrusiveRefCntPtr &A, std::nullptr_t B) { + return !(A == B); + } + //===----------------------------------------------------------------------===// // LLVM-style downcasting support for IntrusiveRefCntPtr objects //===----------------------------------------------------------------------===//