mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-21 18:15:58 +00:00
AK: Add equality operators to compare RefPtr to NonNullRefPtr
This commit is contained in:
parent
ce7d868d6b
commit
63d06458ca
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