diff --git a/AK/Optional.h b/AK/Optional.h index 633b0655ed0..7f96e3a831b 100644 --- a/AK/Optional.h +++ b/AK/Optional.h @@ -339,6 +339,16 @@ public: ALWAYS_INLINE Optional() = default; + template V> + Optional(V) { } + + template V> + Optional& operator=(V) + { + clear(); + return *this; + } + template ALWAYS_INLINE Optional(U& value) requires(CanBePlacedInOptional) @@ -409,6 +419,7 @@ public: // Note: Disallows assignment from a temporary as this does not do any lifetime extension. template + requires(!IsSame>) ALWAYS_INLINE Optional& operator=(U&& value) requires(CanBePlacedInOptional && IsLvalueReference) {