diff --git a/AK/RefPtr.h b/AK/RefPtr.h index 01892e8527..11e27a2c1c 100644 --- a/AK/RefPtr.h +++ b/AK/RefPtr.h @@ -32,6 +32,8 @@ class [[nodiscard]] RefPtr { friend class RefPtr; template friend class WeakPtr; + template + 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 + bool operator==(NonnullRefPtr const& other) const { return as_ptr() == other.m_ptr; } + template + bool operator!=(NonnullRefPtr const& other) const { return as_ptr() != other.m_ptr; } + + template + bool operator==(NonnullRefPtr& other) { return as_ptr() == other.m_ptr; } + template + bool operator!=(NonnullRefPtr& 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; }