mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
AK: Add equality operators to compare RefPtr to NonNullRefPtr
This commit is contained in:
parent
ce7d868d6b
commit
63d06458ca
Notes:
sideshowbarker
2024-07-17 09:34:20 +09:00
Author: https://github.com/AllanRegush Commit: https://github.com/SerenityOS/serenity/commit/63d06458ca Pull-request: https://github.com/SerenityOS/serenity/pull/14330 Issue: https://github.com/SerenityOS/serenity/issues/12779 Reviewed-by: https://github.com/MacDue ✅ Reviewed-by: https://github.com/linusg
1 changed files with 12 additions and 0 deletions
12
AK/RefPtr.h
12
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; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue