diff options
author | Allan Regush <allan@allanregush.com> | 2022-06-18 21:34:44 -0600 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2022-07-09 09:32:51 +0100 |
commit | 63d06458ca929246fcb8f5fc4ea6a34b8a54023f (patch) | |
tree | 8d91604a827bb045f75a03df6f1dd6352bde12f7 /AK/RefPtr.h | |
parent | ce7d868d6b1526d26bfaf532f7a151b8482c271d (diff) | |
download | serenity-63d06458ca929246fcb8f5fc4ea6a34b8a54023f.zip |
AK: Add equality operators to compare RefPtr to NonNullRefPtr
Diffstat (limited to 'AK/RefPtr.h')
-rw-r--r-- | AK/RefPtr.h | 12 |
1 files changed, 12 insertions, 0 deletions
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<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; } |