diff --git a/AK/FlyString.h b/AK/FlyString.h index a0963e6b831..c85f3ee5d67 100644 --- a/AK/FlyString.h +++ b/AK/FlyString.h @@ -155,18 +155,6 @@ public: return *this; } - template - ALWAYS_INLINE bool operator==(Optional const& other) const - { - return has_value() == other.has_value() && (!has_value() || value() == other.value()); - } - - template - ALWAYS_INLINE bool operator==(O const& other) const - { - return has_value() && value() == other; - } - void clear() { m_value = FlyString(nullptr); diff --git a/AK/Optional.h b/AK/Optional.h index 84fe0469423..174232f4a12 100644 --- a/AK/Optional.h +++ b/AK/Optional.h @@ -120,20 +120,6 @@ public: return TRY(callback()); } - template - ALWAYS_INLINE bool operator==(Optional const& other) const - { - return static_cast(*this).has_value() == (other).has_value() - && (!static_cast(*this).has_value() || static_cast(*this).value() == (other).value()); - } - - template - requires(!Detail::IsBaseOf, O>) - ALWAYS_INLINE bool operator==(O const& other) const - { - return static_cast(*this).has_value() && static_cast(*this).value() == other; - } - [[nodiscard]] ALWAYS_INLINE T const& operator*() const { return static_cast(*this).value(); } [[nodiscard]] ALWAYS_INLINE T& operator*() { return static_cast(*this).value(); } @@ -262,18 +248,6 @@ public: return *this; } - template - ALWAYS_INLINE bool operator==(Optional const& other) const - { - return has_value() == other.has_value() && (!has_value() || value() == other.value()); - } - - template - ALWAYS_INLINE bool operator==(O const& other) const - { - return has_value() && value() == other; - } - ALWAYS_INLINE ~Optional() requires(!IsTriviallyDestructible && IsDestructible) { @@ -488,18 +462,6 @@ public: return *exchange(m_pointer, nullptr); } - template - ALWAYS_INLINE bool operator==(Optional const& other) const - { - return has_value() == other.has_value() && (!has_value() || value() == other.value()); - } - - template - ALWAYS_INLINE bool operator==(U const& other) const - { - return has_value() && value() == other; - } - ALWAYS_INLINE AddConstToReferencedType operator*() const { return value(); } ALWAYS_INLINE T operator*() { return value(); } @@ -595,6 +557,19 @@ private: RemoveReference* m_pointer { nullptr }; }; +template +ALWAYS_INLINE bool operator==(Optional const& first, Optional const& second) +{ + return first.has_value() == second.has_value() + && (!first.has_value() || first.value() == second.value()); +} + +template +ALWAYS_INLINE bool operator==(Optional const& first, T2 const& second) +{ + return first.has_value() && first.value() == second; +} + } #if USING_AK_GLOBALLY diff --git a/AK/String.h b/AK/String.h index 825677b9408..71b6e3e51c7 100644 --- a/AK/String.h +++ b/AK/String.h @@ -283,18 +283,6 @@ public: return *this; } - template - ALWAYS_INLINE bool operator==(Optional const& other) const - { - return has_value() == other.has_value() && (!has_value() || value() == other.value()); - } - - template - ALWAYS_INLINE bool operator==(O const& other) const - { - return has_value() && value() == other; - } - void clear() { m_value = String(nullptr); diff --git a/Libraries/LibJS/Runtime/Value.h b/Libraries/LibJS/Runtime/Value.h index 045066fa430..a35410fef5a 100644 --- a/Libraries/LibJS/Runtime/Value.h +++ b/Libraries/LibJS/Runtime/Value.h @@ -593,18 +593,6 @@ public: return *this; } - template - ALWAYS_INLINE bool operator==(Optional const& other) const - { - return has_value() == other.has_value() && (!has_value() || value() == other.value()); - } - - template - ALWAYS_INLINE bool operator==(O const& other) const - { - return has_value() && value() == other; - } - void clear() { m_value = {};