diff --git a/Redcraft.Utility/Source/Public/Templates/Optional.h b/Redcraft.Utility/Source/Public/Templates/Optional.h index 501dad5..5b47fb0 100644 --- a/Redcraft.Utility/Source/Public/Templates/Optional.h +++ b/Redcraft.Utility/Source/Public/Templates/Optional.h @@ -9,7 +9,7 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -template +template requires (TIsObject::Value && !TIsArray::Value&& TIsDestructible::Value) struct TOptional { public: diff --git a/Redcraft.Utility/Source/Public/Templates/Variant.h b/Redcraft.Utility/Source/Public/Templates/Variant.h index a03db66..4f80f92 100644 --- a/Redcraft.Utility/Source/Public/Templates/Variant.h +++ b/Redcraft.Utility/Source/Public/Templates/Variant.h @@ -85,7 +85,7 @@ template constexpr void VariantCopyConstruct(void* Target, const void* Source) { if constexpr (!TIsCopyConstructible::Value || TIsConst::Value) check_no_entry(); - new(reinterpret_cast(Target)) T(*reinterpret_cast(Source)); + else new(reinterpret_cast(Target)) T(*reinterpret_cast(Source)); } using FVariantCopyConstructFunc = void(*)(void*, const void*); @@ -94,7 +94,7 @@ template constexpr void VariantMoveConstruct(void* Target, void* Source) { if constexpr (!TIsMoveConstructible::Value || TIsConst::Value) check_no_entry(); - new(reinterpret_cast(Target)) T(MoveTemp(*reinterpret_cast(Source))); + else new(reinterpret_cast(Target)) T(MoveTemp(*reinterpret_cast(Source))); } using FVariantMoveConstructFunc = void(*)(void*, void*); @@ -103,7 +103,7 @@ template constexpr void VariantCopyAssign(void* Target, const void* Source) { if constexpr (!TIsCopyAssignable::Value || TIsConst::Value) check_no_entry(); - *reinterpret_cast(Target) = *reinterpret_cast(Source); + else *reinterpret_cast(Target) = *reinterpret_cast(Source); } using FVariantCopyAssignFunc = void(*)(void*, const void*); @@ -112,7 +112,7 @@ template constexpr void VariantMoveAssign(void* Target, void* Source) { if constexpr (!TIsMoveAssignable::Value || TIsConst::Value) check_no_entry(); - *reinterpret_cast(Target) = MoveTemp(*reinterpret_cast(Source)); + else *reinterpret_cast(Target) = MoveTemp(*reinterpret_cast(Source)); } using FVariantMoveAssignFunc = void(*)(void*, void*); @@ -149,14 +149,6 @@ struct TVariantHelper static constexpr FVariantInequalityOperatorFunc InequalityOperatorFuncs[] = { VariantInequalityOperator... }; }; -template constexpr FVariantDestroyFunc TVariantHelper::DestroyFuncs[]; -template constexpr FVariantCopyConstructFunc TVariantHelper::CopyConstructFuncs[]; -template constexpr FVariantMoveConstructFunc TVariantHelper::MoveConstructFuncs[]; -template constexpr FVariantCopyAssignFunc TVariantHelper::CopyAssignFuncs[]; -template constexpr FVariantMoveAssignFunc TVariantHelper::MoveAssignFuncs[]; -template constexpr FVariantEqualityOperatorFunc TVariantHelper::EqualityOperatorFuncs[]; -template constexpr FVariantInequalityOperatorFunc TVariantHelper::InequalityOperatorFuncs[]; - template constexpr R VariantVisitLValue(F&& Func, void* Arg) { @@ -210,14 +202,9 @@ struct TVariantVisitHelper static constexpr FVariantVisitConstRValueFunc VisitConstRValueFuncs[] = { VariantVisitConstRValue... }; }; -template constexpr FVariantVisitLValueFunc TVariantVisitHelper::VisitLValueFuncs[]; -template constexpr FVariantVisitRValueFunc TVariantVisitHelper::VisitRValueFuncs[]; -template constexpr FVariantVisitConstLValueFunc TVariantVisitHelper::VisitConstLValueFuncs[]; -template constexpr FVariantVisitConstRValueFunc TVariantVisitHelper::VisitConstRValueFuncs[]; - NAMESPACE_PRIVATE_END -template +template requires (true && ... && (TIsObject::Value && !TIsArray::Value && TIsDestructible::Value)) struct TVariant { struct FAlternativeSize : TConstant { }; @@ -241,7 +228,7 @@ struct TVariant if (GetIndex() != INDEX_NONE) FHelper::MoveConstructFuncs[InValue.GetIndex()](&Value, &InValue.Value); } - template requires (I < FAlternativeSize::Value) + template requires (I < FAlternativeSize::Value) && TIsConstructible::Type, ArgTypes...>::Value constexpr explicit TVariant(TInPlaceIndex, ArgTypes&&... Args) : TypeIndex(I) @@ -250,7 +237,7 @@ struct TVariant new(&Value) SelectedType(Forward(Args)...); } - template requires (TAlternativeIndex::Value != INDEX_NONE) + template requires (TAlternativeIndex::Value != INDEX_NONE) && TIsConstructible::Value>::Type, ArgTypes...>::Value constexpr explicit TVariant(TInPlaceType, ArgTypes&&... Args) : TVariant(InPlaceIndex::Value>, Forward(Args)...)