mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-28 20:29:03 +00:00
AK: Conditionally disable a few variant ctors/assignments
We shouldn't let copy/move ctors or assignments be instantiated if the assignee type does not have a copy/move constructor (even if they're not used anywhere).
This commit is contained in:
parent
7a58c510e5
commit
80e6198563
Notes:
sideshowbarker
2024-07-17 18:45:20 +09:00
Author: https://github.com/alimpfard
Commit: 80e6198563
Pull-request: https://github.com/SerenityOS/serenity/pull/12523
Reviewed-by: https://github.com/IdanHo ✅
1 changed files with 4 additions and 4 deletions
|
@ -129,13 +129,13 @@ struct VariantConstructTag {
|
|||
|
||||
template<typename T, typename Base>
|
||||
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<Detail::VariantConstructors<Ts, Variant<Ts...>>...>::MergeAndDeduplicatePacks;
|
||||
|
||||
template<typename T, typename StrippedT = RemoveCVReference<T>>
|
||||
void set(T&& t) requires(can_contain<StrippedT>())
|
||||
void set(T&& t) requires(can_contain<StrippedT>() && requires { StrippedT(forward<T>(t)); })
|
||||
{
|
||||
constexpr auto new_index = index_of<StrippedT>();
|
||||
Helper::delete_(m_index, m_data);
|
||||
|
@ -345,7 +345,7 @@ public:
|
|||
}
|
||||
|
||||
template<typename T, typename StrippedT = RemoveCVReference<T>>
|
||||
void set(T&& t, Detail::VariantNoClearTag) requires(can_contain<StrippedT>())
|
||||
void set(T&& t, Detail::VariantNoClearTag) requires(can_contain<StrippedT>() && requires { StrippedT(forward<T>(t)); })
|
||||
{
|
||||
constexpr auto new_index = index_of<StrippedT>();
|
||||
new (m_data) StrippedT(forward<T>(t));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue