Bug 1297304 - Add operator== overloads for comparing HandleRefPtrs to their raw Handles. r=bholley

MozReview-Commit-ID: jTQZXyNbqM
This commit is contained in:
Cameron McCormack 2016-08-26 13:59:38 +08:00
parent c6d0866a58
commit c461447b20

View File

@ -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