diff --git a/AK/Optional.h b/AK/Optional.h index 59b1dd1013e..08f659dce41 100644 --- a/AK/Optional.h +++ b/AK/Optional.h @@ -44,6 +44,10 @@ using ConditionallyResultType = typename Detail::ConditionallyResultType class Optional; +struct OptionalNone { + explicit OptionalNone() = default; +}; + template requires(!IsLvalueReference) class [[nodiscard]] Optional { template @@ -56,6 +60,16 @@ public: ALWAYS_INLINE Optional() = default; + template V> + Optional(V) { } + + template V> + Optional& operator=(V) + { + clear(); + return *this; + } + #ifdef AK_HAS_CONDITIONALLY_TRIVIAL Optional(Optional const& other) requires(!IsCopyConstructible) @@ -115,6 +129,7 @@ public: } template + requires(!IsSame>) ALWAYS_INLINE explicit(!IsConvertible) Optional(U&& value) requires(!IsSame, Optional> && IsConstructible) : m_has_value(true)