express: Allow WeakPointer comparisons to nullptr
This saves us from having to do casts like:
if (foo == (const FooType *)nullptr) {
...
}
This commit is contained in:
parent
57602d750f
commit
ebe1b0763f
|
|
@ -292,6 +292,51 @@ operator >= (To *other) const {
|
|||
return (To *)_void_ptr >= other;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class T>
|
||||
INLINE bool WeakPointerToBase<T>::
|
||||
operator == (nullptr_t) const {
|
||||
return _void_ptr == nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class T>
|
||||
INLINE bool WeakPointerToBase<T>::
|
||||
operator != (nullptr_t) const {
|
||||
return _void_ptr != nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class T>
|
||||
INLINE bool WeakPointerToBase<T>::
|
||||
operator > (nullptr_t) const {
|
||||
return _void_ptr != nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class T>
|
||||
INLINE bool WeakPointerToBase<T>::
|
||||
operator <= (nullptr_t) const {
|
||||
return _void_ptr == nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class T>
|
||||
INLINE bool WeakPointerToBase<T>::
|
||||
operator >= (nullptr_t) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
@ -392,6 +437,15 @@ operator < (const To *other) const {
|
|||
return (To *)_void_ptr < other;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class T>
|
||||
INLINE bool WeakPointerToBase<T>::
|
||||
operator < (nullptr_t) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -60,6 +60,12 @@ public:
|
|||
INLINE bool operator <= (To *other) const;
|
||||
INLINE bool operator >= (To *other) const;
|
||||
|
||||
INLINE bool operator == (nullptr_t) const;
|
||||
INLINE bool operator != (nullptr_t) const;
|
||||
INLINE bool operator > (nullptr_t) const;
|
||||
INLINE bool operator <= (nullptr_t) const;
|
||||
INLINE bool operator >= (nullptr_t) const;
|
||||
|
||||
INLINE bool operator == (const WeakPointerToBase<To> &other) const;
|
||||
INLINE bool operator != (const WeakPointerToBase<To> &other) const;
|
||||
INLINE bool operator > (const WeakPointerToBase<To> &other) const;
|
||||
|
|
@ -73,6 +79,7 @@ public:
|
|||
INLINE bool operator >= (const PointerToBase<To> &other) const;
|
||||
#endif // WIN32_VC
|
||||
INLINE bool operator < (const To *other) const;
|
||||
INLINE bool operator < (nullptr_t) const;
|
||||
INLINE bool operator < (const WeakPointerToBase<To> &other) const;
|
||||
INLINE bool operator < (const PointerToBase<To> &other) const;
|
||||
#endif // CPPPARSER
|
||||
|
|
|
|||
Loading…
Reference in New Issue