From: Rafael Espindola Date: Tue, 3 Jun 2014 13:26:18 +0000 (+0000) Subject: Add operator== and operator!= to compare with nullptr. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e9b2cf3456e2ecc04e63f9ea03cfc47ffbb12614;p=oota-llvm.git 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 --- 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 //===----------------------------------------------------------------------===//