aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT/IntrusiveRefCntPtr.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/ADT/IntrusiveRefCntPtr.h')
-rw-r--r--include/llvm/ADT/IntrusiveRefCntPtr.h47
1 files changed, 32 insertions, 15 deletions
diff --git a/include/llvm/ADT/IntrusiveRefCntPtr.h b/include/llvm/ADT/IntrusiveRefCntPtr.h
index cd1946c..f9df378 100644
--- a/include/llvm/ADT/IntrusiveRefCntPtr.h
+++ b/include/llvm/ADT/IntrusiveRefCntPtr.h
@@ -154,13 +154,13 @@ public:
}
template <class X>
- IntrusiveRefCntPtr(IntrusiveRefCntPtr<X>&& S) : Obj(S.getPtr()) {
+ IntrusiveRefCntPtr(IntrusiveRefCntPtr<X>&& S) : Obj(S.get()) {
S.Obj = 0;
}
template <class X>
IntrusiveRefCntPtr(const IntrusiveRefCntPtr<X>& S)
- : Obj(S.getPtr()) {
+ : Obj(S.get()) {
retain();
}
@@ -175,12 +175,9 @@ public:
T* operator->() const { return Obj; }
- T* getPtr() const { return Obj; }
+ T* get() const { return Obj; }
- typedef T* (IntrusiveRefCntPtr::*unspecified_bool_type) () const;
- operator unspecified_bool_type() const {
- return Obj ? &IntrusiveRefCntPtr::getPtr : nullptr;
- }
+ LLVM_EXPLICIT operator bool() const { return Obj; }
void swap(IntrusiveRefCntPtr& other) {
T* tmp = other.Obj;
@@ -206,42 +203,62 @@ public:
inline bool operator==(const IntrusiveRefCntPtr<T>& A,
const IntrusiveRefCntPtr<U>& B)
{
- return A.getPtr() == B.getPtr();
+ return A.get() == B.get();
}
template<class T, class U>
inline bool operator!=(const IntrusiveRefCntPtr<T>& A,
const IntrusiveRefCntPtr<U>& B)
{
- return A.getPtr() != B.getPtr();
+ return A.get() != B.get();
}
template<class T, class U>
inline bool operator==(const IntrusiveRefCntPtr<T>& A,
U* B)
{
- return A.getPtr() == B;
+ return A.get() == B;
}
template<class T, class U>
inline bool operator!=(const IntrusiveRefCntPtr<T>& A,
U* B)
{
- return A.getPtr() != B;
+ return A.get() != B;
}
template<class T, class U>
inline bool operator==(T* A,
const IntrusiveRefCntPtr<U>& B)
{
- return A == B.getPtr();
+ return A == B.get();
}
template<class T, class U>
inline bool operator!=(T* A,
const IntrusiveRefCntPtr<U>& B)
{
- return A != B.getPtr();
+ return A != B.get();
+ }
+
+ 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 B == 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);
}
//===----------------------------------------------------------------------===//
@@ -251,14 +268,14 @@ public:
template<class T> struct simplify_type<IntrusiveRefCntPtr<T> > {
typedef T* SimpleType;
static SimpleType getSimplifiedValue(IntrusiveRefCntPtr<T>& Val) {
- return Val.getPtr();
+ return Val.get();
}
};
template<class T> struct simplify_type<const IntrusiveRefCntPtr<T> > {
typedef /*const*/ T* SimpleType;
static SimpleType getSimplifiedValue(const IntrusiveRefCntPtr<T>& Val) {
- return Val.getPtr();
+ return Val.get();
}
};