AK: Add equality operators to compare RefPtr to NonNullRefPtr

This commit is contained in:
Allan Regush 2022-06-18 21:34:44 -06:00 committed by Sam Atkins
parent ce7d868d6b
commit 63d06458ca

View file

@ -32,6 +32,8 @@ class [[nodiscard]] RefPtr {
friend class RefPtr;
template<typename U>
friend class WeakPtr;
template<typename U>
friend class NonnullRefPtr;
public:
enum AdoptTag {
@ -270,6 +272,16 @@ public:
bool operator==(RefPtr& other) { return as_ptr() == other.as_ptr(); }
bool operator!=(RefPtr& other) { return as_ptr() != other.as_ptr(); }
template<typename U>
bool operator==(NonnullRefPtr<U> const& other) const { return as_ptr() == other.m_ptr; }
template<typename U>
bool operator!=(NonnullRefPtr<U> const& other) const { return as_ptr() != other.m_ptr; }
template<typename U>
bool operator==(NonnullRefPtr<U>& other) { return as_ptr() == other.m_ptr; }
template<typename U>
bool operator!=(NonnullRefPtr<U>& other) { return as_ptr() != other.m_ptr; }
bool operator==(const T* other) const { return as_ptr() == other; }
bool operator!=(const T* other) const { return as_ptr() != other; }