diff --git a/AK/Variant.h b/AK/Variant.h index 63cc349d193..8425f79f7ce 100644 --- a/AK/Variant.h +++ b/AK/Variant.h @@ -129,13 +129,13 @@ struct VariantConstructTag { template struct VariantConstructors { - ALWAYS_INLINE VariantConstructors(T&& t) + ALWAYS_INLINE VariantConstructors(T&& t) requires(requires { T(move(t)); }) { internal_cast().clear_without_destruction(); internal_cast().set(move(t), VariantNoClearTag {}); } - ALWAYS_INLINE VariantConstructors(const T& t) + ALWAYS_INLINE VariantConstructors(const T& t) requires(requires { T(t); }) { internal_cast().clear_without_destruction(); internal_cast().set(t, VariantNoClearTag {}); @@ -336,7 +336,7 @@ public: using Detail::MergeAndDeduplicatePacks>...>::MergeAndDeduplicatePacks; template> - void set(T&& t) requires(can_contain()) + void set(T&& t) requires(can_contain() && requires { StrippedT(forward(t)); }) { constexpr auto new_index = index_of(); Helper::delete_(m_index, m_data); @@ -345,7 +345,7 @@ public: } template> - void set(T&& t, Detail::VariantNoClearTag) requires(can_contain()) + void set(T&& t, Detail::VariantNoClearTag) requires(can_contain() && requires { StrippedT(forward(t)); }) { constexpr auto new_index = index_of(); new (m_data) StrippedT(forward(t));