diff --git a/Redcraft.Utility/Source/Public/Templates/Optional.h b/Redcraft.Utility/Source/Public/Templates/Optional.h index fe4d9b6..35c64ea 100644 --- a/Redcraft.Utility/Source/Public/Templates/Optional.h +++ b/Redcraft.Utility/Source/Public/Templates/Optional.h @@ -53,13 +53,17 @@ public: : TOptional(InPlace, Forward(InValue)) { } - constexpr TOptional(const TOptional& InValue) requires (CCopyConstructible) + constexpr TOptional(const TOptional& InValue) requires (CTriviallyCopyConstructible) = default; + + constexpr TOptional(const TOptional& InValue) requires (CCopyConstructible && !CTriviallyCopyConstructible) : bIsValid(InValue.IsValid()) { if (InValue.IsValid()) new(&Value) OptionalType(InValue.GetValue()); } - constexpr TOptional(TOptional&& InValue) requires (CMoveConstructible) + constexpr TOptional(TOptional&& InValue) requires (CTriviallyMoveConstructible) = default; + + constexpr TOptional(TOptional&& InValue) requires (CMoveConstructible && !CTriviallyMoveConstructible) : bIsValid(InValue.IsValid()) { if (InValue.IsValid()) new(&Value) OptionalType(MoveTemp(InValue.GetValue())); @@ -79,12 +83,17 @@ public: if (InValue.IsValid()) new(&Value) OptionalType(MoveTemp(InValue.GetValue())); } - constexpr ~TOptional() + constexpr ~TOptional() requires (CTriviallyDestructible) = default; + + constexpr ~TOptional() requires (!CTriviallyDestructible) { - if constexpr (!CTriviallyDestructible) Reset(); + Reset(); } - constexpr TOptional& operator=(const TOptional& InValue) requires (CCopyConstructible && CCopyAssignable) + constexpr TOptional& operator=(const TOptional& InValue) requires (CTriviallyCopyConstructible && CTriviallyCopyAssignable) = default; + + constexpr TOptional& operator=(const TOptional& InValue) requires (CCopyConstructible && CCopyAssignable + && !CTriviallyCopyConstructible && !CTriviallyCopyAssignable) { if (&InValue == this) return *this; @@ -104,7 +113,10 @@ public: return *this; } - constexpr TOptional& operator=(TOptional&& InValue) requires (CMoveConstructible && CMoveAssignable) + constexpr TOptional& operator=(TOptional&& InValue) requires (CTriviallyMoveConstructible && CTriviallyMoveAssignable) = default; + + constexpr TOptional& operator=(TOptional&& InValue) requires (CMoveConstructible && CMoveAssignable + && !CTriviallyMoveConstructible && !CTriviallyMoveAssignable) { if (&InValue == this) return *this; diff --git a/Redcraft.Utility/Source/Public/Templates/Variant.h b/Redcraft.Utility/Source/Public/Templates/Variant.h index 53a5ef6..2ca362a 100644 --- a/Redcraft.Utility/Source/Public/Templates/Variant.h +++ b/Redcraft.Utility/Source/Public/Templates/Variant.h @@ -157,13 +157,17 @@ public: constexpr TVariant(FInvalid) : TVariant() { }; - constexpr TVariant(const TVariant& InValue) requires (true && ... && CCopyConstructible) + constexpr TVariant(const TVariant& InValue) requires (true && ... && CTriviallyCopyConstructible) = default; + + constexpr TVariant(const TVariant& InValue) requires ((true && ... && CCopyConstructible) && !(true && ... && CTriviallyCopyConstructible)) : TypeIndex(static_cast(InValue.GetIndex())) { if (IsValid()) CopyConstructImpl[InValue.GetIndex()](&Value, &InValue.Value); } - constexpr TVariant(TVariant&& InValue) requires (true && ... && CMoveConstructible) + constexpr TVariant(TVariant&& InValue) requires (true && ... && CTriviallyMoveConstructible) = default; + + constexpr TVariant(TVariant&& InValue) requires ((true && ... && CMoveConstructible) && !(true && ... && CTriviallyMoveConstructible)) : TypeIndex(static_cast(InValue.GetIndex())) { if (IsValid()) MoveConstructImpl[InValue.GetIndex()](&Value, &InValue.Value); @@ -189,12 +193,17 @@ public: constexpr TVariant(T&& InValue) : TVariant(InPlaceType, Ts...>::Type>, Forward(InValue)) { } - constexpr ~TVariant() + constexpr ~TVariant() requires (true && ... && CTriviallyDestructible) = default; + + constexpr ~TVariant() requires (!(true && ... && CTriviallyDestructible)) { - if constexpr (!(true && ... && CTriviallyDestructible)) Reset(); + Reset(); } - constexpr TVariant& operator=(const TVariant& InValue) requires (true && ... && (CCopyConstructible && CCopyAssignable)) + constexpr TVariant& operator=(const TVariant& InValue) requires (true && ... && (CTriviallyCopyConstructible && CTriviallyCopyAssignable)) = default; + + constexpr TVariant& operator=(const TVariant& InValue) requires ((true && ... && (CCopyConstructible && CCopyAssignable)) + && !(true && ... && (CTriviallyCopyConstructible && CTriviallyCopyAssignable))) { if (&InValue == this) return *this; @@ -215,7 +224,10 @@ public: return *this; } - constexpr TVariant& operator=(TVariant&& InValue) requires (true && ... && (CMoveConstructible && CMoveAssignable)) + constexpr TVariant& operator=(TVariant&& InValue) requires (true && ... && (CTriviallyMoveConstructible && CTriviallyMoveAssignable)) = default; + + constexpr TVariant& operator=(TVariant&& InValue) requires ((true && ... && (CMoveConstructible && CMoveAssignable)) + && !(true && ... && (CTriviallyMoveConstructible && CTriviallyMoveAssignable))) { if (&InValue == this) return *this;