diff --git a/Redcraft.Utility/Source/Public/Templates/Optional.h b/Redcraft.Utility/Source/Public/Templates/Optional.h index 2fb7608..cb712ea 100644 --- a/Redcraft.Utility/Source/Public/Templates/Optional.h +++ b/Redcraft.Utility/Source/Public/Templates/Optional.h @@ -34,13 +34,13 @@ public: : TOptional(InPlace, Forward(InValue)) { } - constexpr TOptional(const TOptional& InValue) + constexpr TOptional(const TOptional& InValue) requires TIsCopyConstructible::Value : bIsValid(InValue.IsValid()) { if (InValue.IsValid()) new(&Value) OptionalType(InValue.GetValue()); } - constexpr TOptional(TOptional&& InValue) + constexpr TOptional(TOptional&& InValue) requires TIsMoveConstructible::Value : bIsValid(InValue.IsValid()) { if (InValue.IsValid()) new(&Value) OptionalType(MoveTemp(InValue.GetValue())); @@ -65,7 +65,7 @@ public: if constexpr (!TIsTriviallyDestructible::Value) Reset(); } - constexpr TOptional& operator=(const TOptional& InValue) + constexpr TOptional& operator=(const TOptional& InValue) requires TIsCopyConstructible::Value && TIsCopyAssignable::Value { if (&InValue == this) return *this; @@ -85,7 +85,7 @@ public: return *this; } - constexpr TOptional& operator=(TOptional&& InValue) + constexpr TOptional& operator=(TOptional&& InValue) requires TIsMoveConstructible::Value && TIsMoveAssignable::Value { if (&InValue == this) return *this; @@ -210,7 +210,7 @@ private: template TOptional(T) ->TOptional; -template +template requires CWeaklyEqualityComparableWith constexpr bool operator==(const TOptional& LHS, const TOptional& RHS) { if (LHS.IsValid() != RHS.IsValid()) return false; @@ -218,7 +218,7 @@ constexpr bool operator==(const TOptional& LHS, const TOptional& RHS) return *LHS == *RHS; } -template +template requires CWeaklyEqualityComparableWith constexpr bool operator!=(const TOptional& LHS, const TOptional& RHS) { if (LHS.IsValid() != RHS.IsValid()) return true; @@ -226,25 +226,25 @@ constexpr bool operator!=(const TOptional& LHS, const TOptional& RHS) return *LHS != *RHS; } -template +template requires CWeaklyEqualityComparableWith constexpr bool operator==(const TOptional& LHS, const U& RHS) { return LHS.IsValid() ? *LHS == RHS : false; } -template +template requires CWeaklyEqualityComparableWith constexpr bool operator!=(const TOptional& LHS, const U& RHS) { return LHS.IsValid() ? *LHS != RHS : true; } -template +template requires CWeaklyEqualityComparableWith constexpr bool operator==(const T& LHS, const TOptional& RHS) { return RHS.IsValid() ? LHS == *RHS : false; } -template +template requires CWeaklyEqualityComparableWith constexpr bool operator!=(const T& LHS, const TOptional& RHS) { return RHS.IsValid() ? LHS != *RHS : true; @@ -274,19 +274,19 @@ constexpr bool operator!=(FInvalid, const TOptional& RHS) return RHS.IsValid(); } -template +template requires (TIsObject::Value && !TIsArray::Value && TIsDestructible::Value) constexpr TOptional::Type> MakeOptional(FInvalid) { return TOptional::Type>(Invalid); } -template +template requires (TIsObject::Value && !TIsArray::Value && TIsDestructible::Value) constexpr TOptional::Type> MakeOptional(T&& InValue) { return TOptional::Type>(Forward(InValue)); } -template +template requires (TIsObject::Value && !TIsArray::Value && TIsDestructible::Value) constexpr TOptional MakeOptional(Types&&... Args) { return TOptional(InPlace, Forward(Args)...); diff --git a/Redcraft.Utility/Source/Public/Templates/Variant.h b/Redcraft.Utility/Source/Public/Templates/Variant.h index 9c662e0..a6f0bd2 100644 --- a/Redcraft.Utility/Source/Public/Templates/Variant.h +++ b/Redcraft.Utility/Source/Public/Templates/Variant.h @@ -216,13 +216,13 @@ struct TVariant constexpr TVariant(FInvalid) : TVariant() { }; - constexpr TVariant(const TVariant& InValue) + constexpr TVariant(const TVariant& InValue) requires (true && ... && TIsCopyConstructible::Value) : TypeIndex(InValue.GetIndex()) { if (GetIndex() != INDEX_NONE) FHelper::CopyConstructFuncs[InValue.GetIndex()](&Value, &InValue.Value); } - constexpr TVariant(TVariant&& InValue) + constexpr TVariant(TVariant&& InValue) requires (true && ... && TIsMoveConstructible::Value) : TypeIndex(InValue.GetIndex()) { if (GetIndex() != INDEX_NONE) FHelper::MoveConstructFuncs[InValue.GetIndex()](&Value, &InValue.Value); @@ -254,7 +254,7 @@ struct TVariant if constexpr (!(true && ... && TIsTriviallyDestructible::Value)) Reset(); } - constexpr TVariant& operator=(const TVariant& InValue) + constexpr TVariant& operator=(const TVariant& InValue) requires (true && ... && (TIsCopyConstructible::Value && TIsCopyAssignable::Value)) { if (&InValue == this) return *this; @@ -275,7 +275,7 @@ struct TVariant return *this; } - constexpr TVariant& operator=(TVariant&& InValue) + constexpr TVariant& operator=(TVariant&& InValue) requires (true && ... && (TIsMoveConstructible::Value && TIsMoveAssignable::Value)) { if (&InValue == this) return *this; @@ -437,14 +437,14 @@ private: TAlignedUnion<1, Types...>::Type Value; size_t TypeIndex; - friend constexpr bool operator==(const TVariant& LHS, const TVariant& RHS) + friend constexpr bool operator==(const TVariant& LHS, const TVariant& RHS) requires (true && ... && CEqualityComparable) { if (LHS.GetIndex() != RHS.GetIndex()) return false; if (LHS.IsValid() == false) return true; return FHelper::EqualityOperatorFuncs[LHS.GetIndex()](&LHS.Value, &RHS.Value); } - friend constexpr bool operator!=(const TVariant& LHS, const TVariant& RHS) + friend constexpr bool operator!=(const TVariant& LHS, const TVariant& RHS) requires (true && ... && CEqualityComparable) { if (LHS.GetIndex() != RHS.GetIndex()) return true; if (LHS.IsValid() == false) return false; @@ -453,25 +453,25 @@ private: }; -template +template requires (!TIsSame>::Value) && CEqualityComparable constexpr bool operator==(const TVariant& LHS, const T& RHS) { return LHS.template HoldsAlternative() ? LHS.template GetValue() == RHS : false; } -template +template requires (!TIsSame>::Value) && CEqualityComparable constexpr bool operator!=(const TVariant& LHS, const T& RHS) { return LHS.template HoldsAlternative() ? LHS.template GetValue() != RHS : true; } -template +template requires (!TIsSame>::Value) && CEqualityComparable constexpr bool operator==(const T& LHS, const TVariant& RHS) { return RHS.template HoldsAlternative() ? LHS == RHS.template GetValue() : false; } -template +template requires (!TIsSame>::Value) && CEqualityComparable constexpr bool operator!=(const T& LHS, const TVariant& RHS) { return RHS.template HoldsAlternative() ? LHS != RHS.template GetValue() : true;