Bug 1294161 - Add operator== overloads for comparing HandlRefPtrs to their raw Handles. r=bholley

MozReview-Commit-ID: jTQZXyNbqM
This commit is contained in:
Cameron McCormack 2016-08-26 14:02:45 +08:00
Родитель 9bfe388f26
Коммит 74db9034ce
1 изменённых файлов: 36 добавлений и 10 удалений

Просмотреть файл

@ -64,16 +64,6 @@ public:
operator T() const { return mHandle; }
T operator->() const { return mHandle; }
bool operator==(const HandleRefPtr<T>& aOther) const
{
return mHandle == aOther.mHandle;
}
bool operator!=(const HandleRefPtr<T>& aOther) const
{
return !(*this == aOther);
}
void swap(HandleRefPtr<T>& aOther)
{
std::swap(mHandle, aOther.mHandle);
@ -102,6 +92,42 @@ private:
T mHandle;
};
template<typename T>
inline bool operator==(const HandleRefPtr<T>& aLHS, const HandleRefPtr<T>& aRHS)
{
return static_cast<T>(aLHS) == static_cast<T>(aRHS);
}
template<typename T>
inline bool operator==(const HandleRefPtr<T>& aLHS, T aRHS)
{
return static_cast<T>(aLHS) == aRHS;
}
template<typename T>
inline bool operator==(T aLHS, const HandleRefPtr<T>& aRHS)
{
return aLHS == static_cast<T>(aRHS);
}
template<typename T>
inline bool operator!=(const HandleRefPtr<T>& aLHS, const HandleRefPtr<T>& aRHS)
{
return !(aLHS == aRHS);
}
template<typename T>
inline bool operator!=(const HandleRefPtr<T>& aLHS, T aRHS)
{
return !(aLHS == aRHS);
}
template<typename T>
inline bool operator!=(T aLHS, const HandleRefPtr<T>& aRHS)
{
return !(aLHS == aRHS);
}
} // namespace mozilla
#endif // mozilla_HandleRefPtr_h