diff --git a/AK/Optional.h b/AK/Optional.h index 7519072a8ad..4453f51d875 100644 --- a/AK/Optional.h +++ b/AK/Optional.h @@ -336,6 +336,9 @@ private: template requires(IsLvalueReference) class [[nodiscard]] Optional { + AK_MAKE_DEFAULT_COPYABLE(Optional); + AK_MAKE_DEFAULT_MOVABLE(Optional); + template friend class Optional; @@ -369,17 +372,6 @@ public: { } - ALWAYS_INLINE Optional(Optional const& other) - : m_pointer(other.m_pointer) - { - } - - ALWAYS_INLINE Optional(Optional&& other) - : m_pointer(other.m_pointer) - { - other.m_pointer = nullptr; - } - template ALWAYS_INLINE Optional(Optional& other) requires(CanBePlacedInOptional) @@ -402,25 +394,6 @@ public: other.m_pointer = nullptr; } - ALWAYS_INLINE Optional& operator=(Optional& other) - { - m_pointer = other.m_pointer; - return *this; - } - - ALWAYS_INLINE Optional& operator=(Optional const& other) - { - m_pointer = other.m_pointer; - return *this; - } - - ALWAYS_INLINE Optional& operator=(Optional&& other) - { - m_pointer = other.m_pointer; - other.m_pointer = nullptr; - return *this; - } - template ALWAYS_INLINE Optional& operator=(Optional& other) requires(CanBePlacedInOptional) diff --git a/Tests/AK/TestOptional.cpp b/Tests/AK/TestOptional.cpp index 2c0f3f49a57..a30e9ec3893 100644 --- a/Tests/AK/TestOptional.cpp +++ b/Tests/AK/TestOptional.cpp @@ -247,7 +247,6 @@ TEST_CASE(move_optional_reference) y = move(x); EXPECT_EQ(y.has_value(), true); EXPECT_EQ(y.value(), 3); - EXPECT_EQ(x.has_value(), false); } TEST_CASE(short_notation_reference)