From d37eee0d23cad6da6a1a95134809fc4edfee7ecd Mon Sep 17 00:00:00 2001 From: _Redstone_c_ Date: Wed, 16 Nov 2022 19:13:37 +0800 Subject: [PATCH] style(*): replaces Types... in the template parameters with Ts... --- .../Source/Public/Miscellaneous/Compare.h | 12 +- .../Source/Public/Templates/Any.h | 36 +-- .../Source/Public/Templates/Function.h | 100 +++--- .../Source/Public/Templates/Invoke.h | 46 +-- .../Source/Public/Templates/Optional.h | 10 +- .../Public/Templates/ReferenceWrapper.h | 12 +- .../Source/Public/Templates/Tuple.h | 306 +++++++++--------- .../Source/Public/Templates/TypeHash.h | 4 +- .../Source/Public/Templates/Variant.h | 208 ++++++------ .../Source/Public/TypeTraits/Common.h | 38 +-- .../Source/Public/TypeTraits/Invocable.h | 8 +- .../Source/Public/TypeTraits/Miscellaneous.h | 4 +- 12 files changed, 392 insertions(+), 392 deletions(-) diff --git a/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h b/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h index d7d9326..07da723 100644 --- a/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h +++ b/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h @@ -24,21 +24,21 @@ template<> struct TCommonComparisonCategoryBasic<2> { using Type = partial_ template<> struct TCommonComparisonCategoryBasic<4> { using Type = weak_ordering; }; template<> struct TCommonComparisonCategoryBasic<6> { using Type = partial_ordering; }; -template +template struct TCommonComparisonCategoryImpl : TCommonComparisonCategoryBasic <(0u | ... | ( - CSameAs ? 0u : - CSameAs ? 4u : - CSameAs ? 2u : 1u + CSameAs ? 0u : + CSameAs ? 4u : + CSameAs ? 2u : 1u ) )> { }; NAMESPACE_PRIVATE_END -template -using TCommonComparisonCategory = typename NAMESPACE_PRIVATE::TCommonComparisonCategoryImpl::Type; +template +using TCommonComparisonCategory = typename NAMESPACE_PRIVATE::TCommonComparisonCategoryImpl::Type; template concept CThreeWayComparesAs = CSameAs, OrderingType>; diff --git a/Redcraft.Utility/Source/Public/Templates/Any.h b/Redcraft.Utility/Source/Public/Templates/Any.h index b32cf9a..adf01c0 100644 --- a/Redcraft.Utility/Source/Public/Templates/Any.h +++ b/Redcraft.Utility/Source/Public/Templates/Any.h @@ -131,12 +131,12 @@ public: } } - template requires CDestructible> - && CConstructibleFrom, Types&&...> - FORCEINLINE explicit TAny(TInPlaceType, Types&&... Args) + template requires CDestructible> + && CConstructibleFrom, Ts&&...> + FORCEINLINE explicit TAny(TInPlaceType, Ts&&... Args) { using SelectedType = TDecay; - EmplaceImpl(Forward(Args)...); + EmplaceImpl(Forward(Args)...); } template requires (!CSameAs, TAny>) && (!CTInPlaceType>) @@ -270,14 +270,14 @@ public: return *this; } - template requires CDestructible> - && CConstructibleFrom, Types&&...> - FORCEINLINE TDecay& Emplace(Types&&... Args) + template requires CDestructible> + && CConstructibleFrom, Ts&&...> + FORCEINLINE TDecay& Emplace(Ts&&... Args) { ResetImpl(); using SelectedType = TDecay; - EmplaceImpl(Forward(Args)...); + EmplaceImpl(Forward(Args)...); return GetValue(); } @@ -400,11 +400,11 @@ private: , TypeSize ( sizeof(T)) , TypeAlignment (alignof(T)) - , CopyConstructImpl ([](void* A, const void* B) { if constexpr (requires(T* A, const T* B) { Memory::CopyConstruct (A, B); }) Memory::CopyConstruct (reinterpret_cast(A), reinterpret_cast(B)); else checkf(false, TEXT("The type '%s' is not copy constructible."), typeid(Types).name()); }) - , MoveConstructImpl ([](void* A, void* B) { if constexpr (requires(T* A, T* B) { Memory::MoveConstruct (A, B); }) Memory::MoveConstruct (reinterpret_cast(A), reinterpret_cast< T*>(B)); else checkf(false, TEXT("The type '%s' is not move constructible."), typeid(Types).name()); }) - , CopyAssignImpl ([](void* A, const void* B) { if constexpr (requires(T* A, const T* B) { Memory::CopyAssign (A, B); }) Memory::CopyAssign (reinterpret_cast(A), reinterpret_cast(B)); else checkf(false, TEXT("The type '%s' is not copy assignable."), typeid(Types).name()); }) - , MoveAssignImpl ([](void* A, void* B) { if constexpr (requires(T* A, T* B) { Memory::MoveAssign (A, B); }) Memory::MoveAssign (reinterpret_cast(A), reinterpret_cast< T*>(B)); else checkf(false, TEXT("The type '%s' is not move assignable."), typeid(Types).name()); }) - , DestroyImpl ([](void* A ) { if constexpr (requires(T* A ) { Memory::Destruct (A ); }) Memory::Destruct (reinterpret_cast(A) ); else checkf(false, TEXT("The type '%s' is not destructible."), typeid(Types).name()); }) + , CopyConstructImpl ([](void* A, const void* B) { if constexpr (requires(T* A, const T* B) { Memory::CopyConstruct (A, B); }) Memory::CopyConstruct (reinterpret_cast(A), reinterpret_cast(B)); else checkf(false, TEXT("The type '%s' is not copy constructible."), typeid(T).name()); }) + , MoveConstructImpl ([](void* A, void* B) { if constexpr (requires(T* A, T* B) { Memory::MoveConstruct (A, B); }) Memory::MoveConstruct (reinterpret_cast(A), reinterpret_cast< T*>(B)); else checkf(false, TEXT("The type '%s' is not move constructible."), typeid(T).name()); }) + , CopyAssignImpl ([](void* A, const void* B) { if constexpr (requires(T* A, const T* B) { Memory::CopyAssign (A, B); }) Memory::CopyAssign (reinterpret_cast(A), reinterpret_cast(B)); else checkf(false, TEXT("The type '%s' is not copy assignable."), typeid(T).name()); }) + , MoveAssignImpl ([](void* A, void* B) { if constexpr (requires(T* A, T* B) { Memory::MoveAssign (A, B); }) Memory::MoveAssign (reinterpret_cast(A), reinterpret_cast< T*>(B)); else checkf(false, TEXT("The type '%s' is not move assignable."), typeid(T).name()); }) + , DestroyImpl ([](void* A ) { if constexpr (requires(T* A ) { Memory::Destruct (A ); }) Memory::Destruct (reinterpret_cast(A) ); else checkf(false, TEXT("The type '%s' is not destructible."), typeid(T).name()); }) , EqualityCompareImpl ([](const void* A, const void* B) -> bool { if constexpr (CEqualityComparable ) return (*reinterpret_cast(A) == *reinterpret_cast(B)); else checkf(false, TEXT("The type '%s' is not equality comparable."), typeid(T).name()); return false; }) , SynthThreeWayCompareImpl ([](const void* A, const void* B) -> partial_ordering { if constexpr (CSynthThreeWayComparable) return NAMESPACE_REDCRAFT::SynthThreeWayCompare (*reinterpret_cast(A), *reinterpret_cast(B)); else checkf(false, TEXT("The type '%s' is not synth three-way comparable."), typeid(T).name()); return partial_ordering::unordered; }) @@ -420,8 +420,8 @@ private: constexpr void* GetAllocation() { return GetRepresentation() == ERepresentation::Trivial || GetRepresentation() == ERepresentation::Small ? Storage.InlineAllocation() : Storage.HeapAllocation(); } constexpr const void* GetAllocation() const { return GetRepresentation() == ERepresentation::Trivial || GetRepresentation() == ERepresentation::Small ? Storage.InlineAllocation() : Storage.HeapAllocation(); } - template - FORCEINLINE void EmplaceImpl(Types&&... Args) + template + FORCEINLINE void EmplaceImpl(Ts&&... Args) { static constexpr const FTypeInfoImpl SelectedTypeInfo(InPlaceType); Storage.TypeInfo() = reinterpret_cast(&SelectedTypeInfo); @@ -431,17 +431,17 @@ private: if constexpr (bIsTriviallyStorable) { - new(Storage.InlineAllocation()) SelectedType(Forward(Args)...); + new(Storage.InlineAllocation()) SelectedType(Forward(Args)...); Storage.TypeInfo() |= static_cast(ERepresentation::Trivial); } else if constexpr (bIsInlineStorable) { - new(Storage.InlineAllocation()) SelectedType(Forward(Args)...); + new(Storage.InlineAllocation()) SelectedType(Forward(Args)...); Storage.TypeInfo() |= static_cast(ERepresentation::Small); } else { - Storage.HeapAllocation() = new SelectedType(Forward(Args)...); + Storage.HeapAllocation() = new SelectedType(Forward(Args)...); Storage.TypeInfo() |= static_cast(ERepresentation::Big); } } diff --git a/Redcraft.Utility/Source/Public/Templates/Function.h b/Redcraft.Utility/Source/Public/Templates/Function.h index 576776a..b30cb56 100644 --- a/Redcraft.Utility/Source/Public/Templates/Function.h +++ b/Redcraft.Utility/Source/Public/Templates/Function.h @@ -56,39 +56,39 @@ constexpr bool FunctionIsBound(const T& Func) template struct TIsInvocableSignature : FFalse { }; -template -struct TIsInvocableSignature - : TBoolConstant && CInvocableResult> +template +struct TIsInvocableSignature + : TBoolConstant && CInvocableResult> { }; -template struct TIsInvocableSignature : TBoolConstant> { }; -template struct TIsInvocableSignature : TBoolConstant> { }; +template struct TIsInvocableSignature : TBoolConstant> { }; +template struct TIsInvocableSignature : TBoolConstant> { }; -template -struct TIsInvocableSignature - : TBoolConstant && CInvocableResult> +template +struct TIsInvocableSignature + : TBoolConstant && CInvocableResult> { }; -template struct TIsInvocableSignature : TBoolConstant> { }; -template struct TIsInvocableSignature : TBoolConstant> { }; +template struct TIsInvocableSignature : TBoolConstant> { }; +template struct TIsInvocableSignature : TBoolConstant> { }; template struct TFunctionInfo; -template struct TFunctionInfo { using Fn = Ret(Types...); using CVRef = int; }; -template struct TFunctionInfo { using Fn = Ret(Types...); using CVRef = int&; }; -template struct TFunctionInfo { using Fn = Ret(Types...); using CVRef = int&&; }; -template struct TFunctionInfo { using Fn = Ret(Types...); using CVRef = const int; }; -template struct TFunctionInfo { using Fn = Ret(Types...); using CVRef = const int&; }; -template struct TFunctionInfo { using Fn = Ret(Types...); using CVRef = const int&&; }; +template struct TFunctionInfo { using Fn = Ret(Ts...); using CVRef = int; }; +template struct TFunctionInfo { using Fn = Ret(Ts...); using CVRef = int&; }; +template struct TFunctionInfo { using Fn = Ret(Ts...); using CVRef = int&&; }; +template struct TFunctionInfo { using Fn = Ret(Ts...); using CVRef = const int; }; +template struct TFunctionInfo { using Fn = Ret(Ts...); using CVRef = const int&; }; +template struct TFunctionInfo { using Fn = Ret(Ts...); using CVRef = const int&&; }; template class TFunctionImpl; -template -class TFunctionImpl +template +class TFunctionImpl { public: using ResultType = Ret; - using ArgumentType = TTuple; + using ArgumentType = TTuple; TFunctionImpl() = default; TFunctionImpl(const TFunctionImpl&) = default; @@ -97,12 +97,12 @@ public: TFunctionImpl& operator=(TFunctionImpl&&) = default; ~TFunctionImpl() = default; - FORCEINLINE ResultType operator()(Types... Args) requires (CSameAs) { return CallImpl(Forward(Args)...); } - FORCEINLINE ResultType operator()(Types... Args) & requires (CSameAs) { return CallImpl(Forward(Args)...); } - FORCEINLINE ResultType operator()(Types... Args) && requires (CSameAs) { return CallImpl(Forward(Args)...); } - FORCEINLINE ResultType operator()(Types... Args) const requires (CSameAs) { return CallImpl(Forward(Args)...); } - FORCEINLINE ResultType operator()(Types... Args) const& requires (CSameAs) { return CallImpl(Forward(Args)...); } - FORCEINLINE ResultType operator()(Types... Args) const&& requires (CSameAs) { return CallImpl(Forward(Args)...); } + FORCEINLINE ResultType operator()(Ts... Args) requires (CSameAs) { return CallImpl(Forward(Args)...); } + FORCEINLINE ResultType operator()(Ts... Args) & requires (CSameAs) { return CallImpl(Forward(Args)...); } + FORCEINLINE ResultType operator()(Ts... Args) && requires (CSameAs) { return CallImpl(Forward(Args)...); } + FORCEINLINE ResultType operator()(Ts... Args) const requires (CSameAs) { return CallImpl(Forward(Args)...); } + FORCEINLINE ResultType operator()(Ts... Args) const& requires (CSameAs) { return CallImpl(Forward(Args)...); } + FORCEINLINE ResultType operator()(Ts... Args) const&& requires (CSameAs) { return CallImpl(Forward(Args)...); } constexpr bool IsValid() const { return GetCallableImpl() != nullptr; } constexpr explicit operator bool() const { return GetCallableImpl() != nullptr; } @@ -140,7 +140,7 @@ public: private: using StoragePtrType = TCopyConst*; - using CallableType = ResultType(*)(StoragePtrType, Types&&...); + using CallableType = ResultType(*)(StoragePtrType, Ts&&...); struct FunctionRefStorage { @@ -193,18 +193,18 @@ private: else return Storage.GetCustomStorage().Callable; } - FORCEINLINE ResultType CallImpl(Types&&... Args) + FORCEINLINE ResultType CallImpl(Ts&&... Args) { checkf(IsValid(), TEXT("Attempting to call an unbound TFunction!")); - if constexpr (bIsRef) return GetCallableImpl()(Storage.Ptr, Forward(Args)...); - else return GetCallableImpl()(&Storage, Forward(Args)...); + if constexpr (bIsRef) return GetCallableImpl()(Storage.Ptr, Forward(Args)...); + else return GetCallableImpl()(&Storage, Forward(Args)...); } - FORCEINLINE ResultType CallImpl(Types&&... Args) const + FORCEINLINE ResultType CallImpl(Ts&&... Args) const { checkf(IsValid(), TEXT("Attempting to call an unbound TFunction!")); - if constexpr (bIsRef) return GetCallableImpl()(Storage.Ptr, Forward(Args)...); - else return GetCallableImpl()(&Storage, Forward(Args)...); + if constexpr (bIsRef) return GetCallableImpl()(Storage.Ptr, Forward(Args)...); + else return GetCallableImpl()(&Storage, Forward(Args)...); } protected: // These functions should not be used by user-defined class. @@ -217,7 +217,7 @@ protected: // These functions should not be used by user-defined class. if constexpr (bIsRef) Storage.Ptr = (AddressOf(Args), ...); else Storage.template Emplace(Forward(Args)...); - GetCallableImpl() = [](StoragePtrType Storage, Types&&... Args) -> ResultType + GetCallableImpl() = [](StoragePtrType Storage, Ts&&... Args) -> ResultType { using InvokeType = TConditional< CReference, @@ -231,7 +231,7 @@ protected: // These functions should not be used by user-defined class. else return static_cast(*reinterpret_cast(Storage)); }; - return InvokeResult(GetFunc(), Forward(Args)...); + return InvokeResult(GetFunc(), Forward(Args)...); }; } @@ -508,32 +508,32 @@ struct TNotFunction template constexpr TNotFunction(InF&& InFunc) : Storage(Forward(InFunc)) { } - template requires CInvocable - constexpr auto operator()(Types&&... Args) & - -> decltype(!Invoke(Storage, Forward(Args)...)) + template requires CInvocable + constexpr auto operator()(Ts&&... Args) & + -> decltype(!Invoke(Storage, Forward(Args)...)) { - return !Invoke(Storage, Forward(Args)...); + return !Invoke(Storage, Forward(Args)...); } - template requires CInvocable - constexpr auto operator()(Types&&... Args) && - -> decltype(!Invoke(MoveTemp(Storage), Forward(Args)...)) + template requires CInvocable + constexpr auto operator()(Ts&&... Args) && + -> decltype(!Invoke(MoveTemp(Storage), Forward(Args)...)) { - return !Invoke(MoveTemp(Storage), Forward(Args)...); + return !Invoke(MoveTemp(Storage), Forward(Args)...); } - template requires CInvocable - constexpr auto operator()(Types&&... Args) const& - -> decltype(!Invoke(Storage, Forward(Args)...)) + template requires CInvocable + constexpr auto operator()(Ts&&... Args) const& + -> decltype(!Invoke(Storage, Forward(Args)...)) { - return !Invoke(Storage, Forward(Args)...); + return !Invoke(Storage, Forward(Args)...); } - template requires CInvocable - constexpr auto operator()(Types&&... Args) const&& - -> decltype(!Invoke(MoveTemp(Storage), Forward(Args)...)) + template requires CInvocable + constexpr auto operator()(Ts&&... Args) const&& + -> decltype(!Invoke(MoveTemp(Storage), Forward(Args)...)) { - return !Invoke(MoveTemp(Storage), Forward(Args)...); + return !Invoke(MoveTemp(Storage), Forward(Args)...); } }; diff --git a/Redcraft.Utility/Source/Public/Templates/Invoke.h b/Redcraft.Utility/Source/Public/Templates/Invoke.h index 114110d..9f99a61 100644 --- a/Redcraft.Utility/Source/Public/Templates/Invoke.h +++ b/Redcraft.Utility/Source/Public/Templates/Invoke.h @@ -12,28 +12,28 @@ NAMESPACE_PRIVATE_BEGIN struct InvokeFunction { - template - static auto Invoke(F&& Object, Types&&... Args) - -> decltype(Forward(Object)(Forward(Args)...)) + template + static auto Invoke(F&& Object, Ts&&... Args) + -> decltype(Forward(Object)(Forward(Args)...)) { - return Forward(Object)(Forward(Args)...); + return Forward(Object)(Forward(Args)...); } }; struct InvokeMemberFunction { - template - static auto Invoke(F&& Func, ObjectType&& Object, Types&&... Args) - -> decltype((Forward(Object)->*Func)(Forward(Args)...)) + template + static auto Invoke(F&& Func, ObjectType&& Object, Ts&&... Args) + -> decltype((Forward(Object)->*Func)(Forward(Args)...)) { - return (Forward(Object)->*Func)(Forward(Args)...); + return (Forward(Object)->*Func)(Forward(Args)...); } - template - static auto Invoke(F&& Func, ObjectType&& Object, Types&&... Args) - -> decltype((Forward(Object).*Func)(Forward(Args)...)) + template + static auto Invoke(F&& Func, ObjectType&& Object, Ts&&... Args) + -> decltype((Forward(Object).*Func)(Forward(Args)...)) { - return (Forward(Object).*Func)(Forward(Args)...); + return (Forward(Object).*Func)(Forward(Args)...); } }; @@ -70,29 +70,29 @@ struct InvokeMember : InvokeMemberObject { }; template struct InvokeMember : InvokeFunction { }; -template +template struct InvokeImpl; template struct InvokeImpl : InvokeFunction { }; -template -struct InvokeImpl : InvokeMember { }; +template +struct InvokeImpl : InvokeMember { }; NAMESPACE_PRIVATE_END -template requires CInvocable -constexpr auto Invoke(F&& Func, Types&&... Args) - -> decltype(NAMESPACE_PRIVATE::InvokeImpl::Invoke(Forward(Func), Forward(Args)...)) +template requires CInvocable +constexpr auto Invoke(F&& Func, Ts&&... Args) + -> decltype(NAMESPACE_PRIVATE::InvokeImpl::Invoke(Forward(Func), Forward(Args)...)) { - return NAMESPACE_PRIVATE::InvokeImpl::Invoke(Forward(Func), Forward(Args)...); + return NAMESPACE_PRIVATE::InvokeImpl::Invoke(Forward(Func), Forward(Args)...); } -template requires CInvocableResult -constexpr R InvokeResult(F&& Func, Types&&... Args) +template requires CInvocableResult +constexpr R InvokeResult(F&& Func, Ts&&... Args) { - if constexpr (CVoid) Invoke(Forward(Func), Forward(Args)...); - else return Invoke(Forward(Func), Forward(Args)...); + if constexpr (CVoid) Invoke(Forward(Func), Forward(Args)...); + else return Invoke(Forward(Func), Forward(Args)...); } NAMESPACE_MODULE_END(Utility) diff --git a/Redcraft.Utility/Source/Public/Templates/Optional.h b/Redcraft.Utility/Source/Public/Templates/Optional.h index a794cdd..e3fdb44 100644 --- a/Redcraft.Utility/Source/Public/Templates/Optional.h +++ b/Redcraft.Utility/Source/Public/Templates/Optional.h @@ -40,11 +40,11 @@ public: constexpr TOptional(FInvalid) : TOptional() { } - template requires CConstructibleFrom - constexpr explicit TOptional(FInPlace, Types&&... Args) + template requires CConstructibleFrom + constexpr explicit TOptional(FInPlace, Ts&&... Args) : bIsValid(true) { - new(&Value) OptionalType(Forward(Args)...); + new(&Value) OptionalType(Forward(Args)...); } template requires CConstructibleFrom @@ -296,8 +296,8 @@ constexpr TOptional MakeOptional(T&& InValue) return TOptional(Forward(InValue)); } -template requires CDestructible && CConstructibleFrom -constexpr TOptional MakeOptional(Types&&... Args) +template requires CDestructible && CConstructibleFrom +constexpr TOptional MakeOptional(Ts&&... Args) { return TOptional(InPlace, Forward(Args)...); } diff --git a/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h b/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h index 3ceb3ff..0270404 100644 --- a/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h +++ b/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h @@ -43,10 +43,10 @@ public: constexpr operator ReferencedType&() const { return *Pointer; } constexpr ReferencedType& Get() const { return *Pointer; } - template - constexpr TInvokeResult operator()(Types&&... Args) const + template + constexpr TInvokeResult operator()(Ts&&... Args) const { - return Invoke(Get(), Forward(Args)...); + return Invoke(Get(), Forward(Args)...); } constexpr size_t GetTypeHash() const requires CHashable @@ -155,9 +155,9 @@ public: constexpr TOptional(FInvalid) : TOptional() { } - template requires CConstructibleFrom - constexpr explicit TOptional(FInPlace, Types&&... Args) - : Reference(Forward(Args)...) + template requires CConstructibleFrom + constexpr explicit TOptional(FInPlace, Ts&&... Args) + : Reference(Forward(Args)...) { } template requires CConstructibleFrom diff --git a/Redcraft.Utility/Source/Public/Templates/Tuple.h b/Redcraft.Utility/Source/Public/Templates/Tuple.h index 49db784..1a7a5c1 100644 --- a/Redcraft.Utility/Source/Public/Templates/Tuple.h +++ b/Redcraft.Utility/Source/Public/Templates/Tuple.h @@ -16,13 +16,13 @@ NAMESPACE_MODULE_BEGIN(Utility) #define RS_TUPLE_ELEMENT_STATIC_ALIAS 1 -template +template class TTuple; NAMESPACE_PRIVATE_BEGIN template struct TIsTTuple : FFalse { }; -template struct TIsTTuple> : FTrue { }; +template struct TIsTTuple> : FTrue { }; struct FForwardingConstructor { explicit FForwardingConstructor() = default; }; struct FOtherTupleConstructor { explicit FOtherTupleConstructor() = default; }; @@ -33,74 +33,74 @@ inline constexpr FOtherTupleConstructor OtherTupleConstructor{ }; template struct TTupleArityImpl; -template -struct TTupleArityImpl> : TConstant { }; +template +struct TTupleArityImpl> : TConstant { }; -template -struct TTupleArityImpl> : TConstant { }; +template +struct TTupleArityImpl> : TConstant { }; -template -struct TTupleArityImpl> : TConstant { }; +template +struct TTupleArityImpl> : TConstant { }; -template -struct TTupleArityImpl> : TConstant { }; +template +struct TTupleArityImpl> : TConstant { }; template struct TTupleIndexImpl; -template -struct TTupleIndexImpl> : TConstant>::Value + 1> +template +struct TTupleIndexImpl> : TConstant>::Value + 1> { - static_assert(sizeof...(Types) != 0, "Non-existent types in tuple"); + static_assert(sizeof...(Ts) != 0, "Non-existent types in tuple"); }; -template -struct TTupleIndexImpl> : TConstant +template +struct TTupleIndexImpl> : TConstant { - static_assert((true && ... && !CSameAs), "Duplicate type in tuple"); + static_assert((true && ... && !CSameAs), "Duplicate type in tuple"); }; template struct TTupleIndexImpl> : TConstant { }; -template -struct TTupleIndexImpl> : TTupleIndexImpl> { }; +template +struct TTupleIndexImpl> : TTupleIndexImpl> { }; -template -struct TTupleIndexImpl> : TTupleIndexImpl> { }; +template +struct TTupleIndexImpl> : TTupleIndexImpl> { }; -template -struct TTupleIndexImpl> : TTupleIndexImpl> { }; +template +struct TTupleIndexImpl> : TTupleIndexImpl> { }; template struct TTupleElementImpl; -template -struct TTupleElementImpl> +template +struct TTupleElementImpl> { - static_assert(I < sizeof...(Types) + 1, "Invalid index in tuple"); - using Type = TTupleElementImpl>::Type; + static_assert(I < sizeof...(Ts) + 1, "Invalid index in tuple"); + using Type = TTupleElementImpl>::Type; }; -template -struct TTupleElementImpl<0, TTuple> { using Type = T; }; +template +struct TTupleElementImpl<0, TTuple> { using Type = T; }; -template -struct TTupleElementImpl> { }; +template +struct TTupleElementImpl> { }; template <> struct TTupleElementImpl<0, TTuple<>> { }; -template -struct TTupleElementImpl> { using Type = TAddConst>::Type>; }; +template +struct TTupleElementImpl> { using Type = TAddConst>::Type>; }; -template -struct TTupleElementImpl> { using Type = TAddVolatile>::Type>; }; +template +struct TTupleElementImpl> { using Type = TAddVolatile>::Type>; }; -template -struct TTupleElementImpl> { using Type = TAddCV>::Type>; }; +template +struct TTupleElementImpl> { using Type = TAddCV>::Type>; }; -template +template struct TTupleConvertCopy : FTrue { }; template @@ -110,7 +110,7 @@ struct TTupleConvertCopy || CSameAs)> { }; -template +template struct TTupleConvertMove : FTrue { }; template @@ -202,17 +202,17 @@ DEFINE_TTupleBasicElement(0xF, Sixteenth); #endif -template -constexpr TTuple...> MakeTupleImpl(Types&&... Args) +template +constexpr TTuple...> MakeTupleImpl(Ts&&... Args) { - return TTuple...>(Forward(Args)...); + return TTuple...>(Forward(Args)...); } -template +template class TTupleImpl; -template -class TTupleImpl, Types...> : public TTupleBasicElement... +template +class TTupleImpl, Ts...> : public TTupleBasicElement... { protected: @@ -220,12 +220,12 @@ protected: template explicit TTupleImpl(FForwardingConstructor, ArgTypes&&... Args) - : TTupleBasicElement(Forward(Args))... + : TTupleBasicElement(Forward(Args))... { } template explicit TTupleImpl(FOtherTupleConstructor, TupleType&& InValue) - : TTupleBasicElement(Forward(InValue).template GetValue())... + : TTupleBasicElement(Forward(InValue).template GetValue())... { } TTupleImpl(const TTupleImpl&) = default; @@ -236,7 +236,7 @@ protected: }; -template +template class TTupleHelper; template @@ -300,51 +300,51 @@ inline constexpr size_t TTupleIndex = NAMESPACE_PRIVATE::TTupleIndexImpl using TTupleElement = typename NAMESPACE_PRIVATE::TTupleElementImpl::Type; -template -class TTuple : public NAMESPACE_PRIVATE::TTupleImpl, Types...> +template +class TTuple : public NAMESPACE_PRIVATE::TTupleImpl, Ts...> { private: - using Super = NAMESPACE_PRIVATE::TTupleImpl, Types...>; - using Helper = NAMESPACE_PRIVATE::TTupleHelper>; + using Super = NAMESPACE_PRIVATE::TTupleImpl, Ts...>; + using Helper = NAMESPACE_PRIVATE::TTupleHelper>; public: TTuple() = default; - template requires (sizeof...(Types) >= 1) && (sizeof...(ArgTypes) == sizeof...(Types)) - && (true && ... && CConstructibleFrom) - constexpr explicit (!(true && ... && CConvertibleTo)) TTuple(ArgTypes&&... Args) + template requires (sizeof...(Ts) >= 1) && (sizeof...(ArgTypes) == sizeof...(Ts)) + && (true && ... && CConstructibleFrom) + constexpr explicit (!(true && ... && CConvertibleTo)) TTuple(ArgTypes&&... Args) : Super(NAMESPACE_PRIVATE::ForwardingConstructor, Forward(Args)...) { } - template requires (sizeof...(OtherTypes) == sizeof...(Types)) - && (true && ... && CConstructibleFrom) - && NAMESPACE_PRIVATE::TTupleConvertCopy::Value - constexpr explicit (!(true && ... && CConvertibleTo)) TTuple(const TTuple& InValue) + template requires (sizeof...(OtherTypes) == sizeof...(Ts)) + && (true && ... && CConstructibleFrom) + && NAMESPACE_PRIVATE::TTupleConvertCopy::Value + constexpr explicit (!(true && ... && CConvertibleTo)) TTuple(const TTuple& InValue) : Super(NAMESPACE_PRIVATE::OtherTupleConstructor, InValue) { } - template requires (sizeof...(OtherTypes) == sizeof...(Types)) - && (true && ... && CConstructibleFrom) - && NAMESPACE_PRIVATE::TTupleConvertMove::Value - constexpr explicit (!(true && ... && CConvertibleTo)) TTuple(TTuple&& InValue) + template requires (sizeof...(OtherTypes) == sizeof...(Ts)) + && (true && ... && CConstructibleFrom) + && NAMESPACE_PRIVATE::TTupleConvertMove::Value + constexpr explicit (!(true && ... && CConvertibleTo)) TTuple(TTuple&& InValue) : Super(NAMESPACE_PRIVATE::OtherTupleConstructor, MoveTemp(InValue)) { } TTuple(const TTuple&) = default; TTuple(TTuple&&) = default; - template requires (sizeof...(OtherTypes) == sizeof...(Types)) - && (true && ... && CAssignableFrom) + template requires (sizeof...(OtherTypes) == sizeof...(Ts)) + && (true && ... && CAssignableFrom) constexpr TTuple& operator=(const TTuple& InValue) { Helper::Assign(*this, InValue); return *this; } - template requires (sizeof...(OtherTypes) == sizeof...(Types)) - && (true && ... && CAssignableFrom) + template requires (sizeof...(OtherTypes) == sizeof...(Ts)) + && (true && ... && CAssignableFrom) constexpr TTuple& operator=(TTuple&& InValue) { Helper::Assign(*this, MoveTemp(InValue)); @@ -354,111 +354,111 @@ public: TTuple& operator=(const TTuple&) = default; TTuple& operator=(TTuple&&) = default; - template requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() & { return static_cast< NAMESPACE_PRIVATE::TTupleBasicElement>, I>& >(*this).GetValue(); } - template requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() const & { return static_cast>, I>& >(*this).GetValue(); } - template requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() volatile& { return static_cast< volatile NAMESPACE_PRIVATE::TTupleBasicElement>, I>& >(*this).GetValue(); } - template requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() const volatile& { return static_cast>, I>& >(*this).GetValue(); } - template requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() && { return static_cast< NAMESPACE_PRIVATE::TTupleBasicElement>, I>&&>(*this).GetValue(); } - template requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() const && { return static_cast>, I>&&>(*this).GetValue(); } - template requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() volatile&& { return static_cast< volatile NAMESPACE_PRIVATE::TTupleBasicElement>, I>&&>(*this).GetValue(); } - template requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() const volatile&& { return static_cast>, I>&&>(*this).GetValue(); } + template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() & { return static_cast< NAMESPACE_PRIVATE::TTupleBasicElement>, I>& >(*this).GetValue(); } + template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const & { return static_cast>, I>& >(*this).GetValue(); } + template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() volatile& { return static_cast< volatile NAMESPACE_PRIVATE::TTupleBasicElement>, I>& >(*this).GetValue(); } + template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const volatile& { return static_cast>, I>& >(*this).GetValue(); } + template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() && { return static_cast< NAMESPACE_PRIVATE::TTupleBasicElement>, I>&&>(*this).GetValue(); } + template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const && { return static_cast>, I>&&>(*this).GetValue(); } + template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() volatile&& { return static_cast< volatile NAMESPACE_PRIVATE::TTupleBasicElement>, I>&&>(*this).GetValue(); } + template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const volatile&& { return static_cast>, I>&&>(*this).GetValue(); } - template constexpr decltype(auto) GetValue() & { return static_cast< TTuple& >(*this).GetValue>>(); } - template constexpr decltype(auto) GetValue() const & { return static_cast(*this).GetValue>>(); } - template constexpr decltype(auto) GetValue() volatile& { return static_cast< volatile TTuple& >(*this).GetValue>>(); } - template constexpr decltype(auto) GetValue() const volatile& { return static_cast(*this).GetValue>>(); } - template constexpr decltype(auto) GetValue() && { return static_cast< TTuple&&>(*this).GetValue>>(); } - template constexpr decltype(auto) GetValue() const && { return static_cast(*this).GetValue>>(); } - template constexpr decltype(auto) GetValue() volatile&& { return static_cast< volatile TTuple&&>(*this).GetValue>>(); } - template constexpr decltype(auto) GetValue() const volatile&& { return static_cast(*this).GetValue>>(); } + template constexpr decltype(auto) GetValue() & { return static_cast< TTuple& >(*this).GetValue>>(); } + template constexpr decltype(auto) GetValue() const & { return static_cast(*this).GetValue>>(); } + template constexpr decltype(auto) GetValue() volatile& { return static_cast< volatile TTuple& >(*this).GetValue>>(); } + template constexpr decltype(auto) GetValue() const volatile& { return static_cast(*this).GetValue>>(); } + template constexpr decltype(auto) GetValue() && { return static_cast< TTuple&&>(*this).GetValue>>(); } + template constexpr decltype(auto) GetValue() const && { return static_cast(*this).GetValue>>(); } + template constexpr decltype(auto) GetValue() volatile&& { return static_cast< volatile TTuple&&>(*this).GetValue>>(); } + template constexpr decltype(auto) GetValue() const volatile&& { return static_cast(*this).GetValue>>(); } - template requires CInvocable constexpr decltype(auto) Apply(F&& Func) & { return Helper::Apply(Forward(Func), static_cast< TTuple& >(*this)); } - template requires CInvocable constexpr decltype(auto) Apply(F&& Func) const & { return Helper::Apply(Forward(Func), static_cast(*this)); } - template requires CInvocable constexpr decltype(auto) Apply(F&& Func) volatile& { return Helper::Apply(Forward(Func), static_cast< volatile TTuple& >(*this)); } - template requires CInvocable constexpr decltype(auto) Apply(F&& Func) const volatile& { return Helper::Apply(Forward(Func), static_cast(*this)); } - template requires CInvocable constexpr decltype(auto) Apply(F&& Func) && { return Helper::Apply(Forward(Func), static_cast< TTuple&&>(*this)); } - template requires CInvocable constexpr decltype(auto) Apply(F&& Func) const && { return Helper::Apply(Forward(Func), static_cast(*this)); } - template requires CInvocable constexpr decltype(auto) Apply(F&& Func) volatile&& { return Helper::Apply(Forward(Func), static_cast< volatile TTuple&&>(*this)); } - template requires CInvocable constexpr decltype(auto) Apply(F&& Func) const volatile&& { return Helper::Apply(Forward(Func), static_cast(*this)); } + template requires CInvocable constexpr decltype(auto) Apply(F&& Func) & { return Helper::Apply(Forward(Func), static_cast< TTuple& >(*this)); } + template requires CInvocable constexpr decltype(auto) Apply(F&& Func) const & { return Helper::Apply(Forward(Func), static_cast(*this)); } + template requires CInvocable constexpr decltype(auto) Apply(F&& Func) volatile& { return Helper::Apply(Forward(Func), static_cast< volatile TTuple& >(*this)); } + template requires CInvocable constexpr decltype(auto) Apply(F&& Func) const volatile& { return Helper::Apply(Forward(Func), static_cast(*this)); } + template requires CInvocable constexpr decltype(auto) Apply(F&& Func) && { return Helper::Apply(Forward(Func), static_cast< TTuple&&>(*this)); } + template requires CInvocable constexpr decltype(auto) Apply(F&& Func) const && { return Helper::Apply(Forward(Func), static_cast(*this)); } + template requires CInvocable constexpr decltype(auto) Apply(F&& Func) volatile&& { return Helper::Apply(Forward(Func), static_cast< volatile TTuple&&>(*this)); } + template requires CInvocable constexpr decltype(auto) Apply(F&& Func) const volatile&& { return Helper::Apply(Forward(Func), static_cast(*this)); } - template requires CInvocable constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) & { return Helper::ApplyAfter(Forward(Func), static_cast< TTuple& >(*this), Forward(Args)...); } - template requires CInvocable constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const & { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires CInvocable constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) volatile& { return Helper::ApplyAfter(Forward(Func), static_cast< volatile TTuple& >(*this), Forward(Args)...); } - template requires CInvocable constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const volatile& { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires CInvocable constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) && { return Helper::ApplyAfter(Forward(Func), static_cast< TTuple&&>(*this), Forward(Args)...); } - template requires CInvocable constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const && { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires CInvocable constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) volatile&& { return Helper::ApplyAfter(Forward(Func), static_cast< volatile TTuple&&>(*this), Forward(Args)...); } - template requires CInvocable constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const volatile&& { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } + template requires CInvocable constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) & { return Helper::ApplyAfter(Forward(Func), static_cast< TTuple& >(*this), Forward(Args)...); } + template requires CInvocable constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const & { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } + template requires CInvocable constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) volatile& { return Helper::ApplyAfter(Forward(Func), static_cast< volatile TTuple& >(*this), Forward(Args)...); } + template requires CInvocable constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const volatile& { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } + template requires CInvocable constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) && { return Helper::ApplyAfter(Forward(Func), static_cast< TTuple&&>(*this), Forward(Args)...); } + template requires CInvocable constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const && { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } + template requires CInvocable constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) volatile&& { return Helper::ApplyAfter(Forward(Func), static_cast< volatile TTuple&&>(*this), Forward(Args)...); } + template requires CInvocable constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const volatile&& { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires CInvocable constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) & { return Helper::ApplyBefore(Forward(Func), static_cast< TTuple& >(*this), Forward(Args)...); } - template requires CInvocable constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const & { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires CInvocable constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) volatile& { return Helper::ApplyBefore(Forward(Func), static_cast< volatile TTuple& >(*this), Forward(Args)...); } - template requires CInvocable constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const volatile& { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires CInvocable constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) && { return Helper::ApplyBefore(Forward(Func), static_cast< TTuple&&>(*this), Forward(Args)...); } - template requires CInvocable constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const && { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires CInvocable constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) volatile&& { return Helper::ApplyBefore(Forward(Func), static_cast< volatile TTuple&&>(*this), Forward(Args)...); } - template requires CInvocable constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const volatile&& { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } + template requires CInvocable constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) & { return Helper::ApplyBefore(Forward(Func), static_cast< TTuple& >(*this), Forward(Args)...); } + template requires CInvocable constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const & { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } + template requires CInvocable constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) volatile& { return Helper::ApplyBefore(Forward(Func), static_cast< volatile TTuple& >(*this), Forward(Args)...); } + template requires CInvocable constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const volatile& { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } + template requires CInvocable constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) && { return Helper::ApplyBefore(Forward(Func), static_cast< TTuple&&>(*this), Forward(Args)...); } + template requires CInvocable constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const && { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } + template requires CInvocable constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) volatile&& { return Helper::ApplyBefore(Forward(Func), static_cast< volatile TTuple&&>(*this), Forward(Args)...); } + template requires CInvocable constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const volatile&& { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) & { return Helper::Transform(Forward(Func), static_cast< TTuple& >(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) const & { return Helper::Transform(Forward(Func), static_cast(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) volatile& { return Helper::Transform(Forward(Func), static_cast< volatile TTuple& >(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) const volatile& { return Helper::Transform(Forward(Func), static_cast(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) && { return Helper::Transform(Forward(Func), static_cast< TTuple&&>(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) const && { return Helper::Transform(Forward(Func), static_cast(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) volatile&& { return Helper::Transform(Forward(Func), static_cast< volatile TTuple&&>(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) const volatile&& { return Helper::Transform(Forward(Func), static_cast(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) & { return Helper::Transform(Forward(Func), static_cast< TTuple& >(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) const & { return Helper::Transform(Forward(Func), static_cast(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) volatile& { return Helper::Transform(Forward(Func), static_cast< volatile TTuple& >(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) const volatile& { return Helper::Transform(Forward(Func), static_cast(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) && { return Helper::Transform(Forward(Func), static_cast< TTuple&&>(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) const && { return Helper::Transform(Forward(Func), static_cast(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) volatile&& { return Helper::Transform(Forward(Func), static_cast< volatile TTuple&&>(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) const volatile&& { return Helper::Transform(Forward(Func), static_cast(*this)); } - template requires CConstructibleFrom constexpr T Construct() & { return Helper::template Construct(static_cast< TTuple& >(*this)); } - template requires CConstructibleFrom constexpr T Construct() const & { return Helper::template Construct(static_cast(*this)); } - template requires CConstructibleFrom constexpr T Construct() volatile& { return Helper::template Construct(static_cast< volatile TTuple& >(*this)); } - template requires CConstructibleFrom constexpr T Construct() const volatile& { return Helper::template Construct(static_cast(*this)); } - template requires CConstructibleFrom constexpr T Construct() && { return Helper::template Construct(static_cast< TTuple&&>(*this)); } - template requires CConstructibleFrom constexpr T Construct() const && { return Helper::template Construct(static_cast(*this)); } - template requires CConstructibleFrom constexpr T Construct() volatile&& { return Helper::template Construct(static_cast< volatile TTuple&&>(*this)); } - template requires CConstructibleFrom constexpr T Construct() const volatile&& { return Helper::template Construct(static_cast(*this)); } + template requires CConstructibleFrom constexpr T Construct() & { return Helper::template Construct(static_cast< TTuple& >(*this)); } + template requires CConstructibleFrom constexpr T Construct() const & { return Helper::template Construct(static_cast(*this)); } + template requires CConstructibleFrom constexpr T Construct() volatile& { return Helper::template Construct(static_cast< volatile TTuple& >(*this)); } + template requires CConstructibleFrom constexpr T Construct() const volatile& { return Helper::template Construct(static_cast(*this)); } + template requires CConstructibleFrom constexpr T Construct() && { return Helper::template Construct(static_cast< TTuple&&>(*this)); } + template requires CConstructibleFrom constexpr T Construct() const && { return Helper::template Construct(static_cast(*this)); } + template requires CConstructibleFrom constexpr T Construct() volatile&& { return Helper::template Construct(static_cast< volatile TTuple&&>(*this)); } + template requires CConstructibleFrom constexpr T Construct() const volatile&& { return Helper::template Construct(static_cast(*this)); } - constexpr size_t GetTypeHash() const requires (true && ... && CHashable) + constexpr size_t GetTypeHash() const requires (true && ... && CHashable) { return [this](TIndexSequence) -> size_t { return HashCombine(NAMESPACE_REDCRAFT::GetTypeHash(GetValue())...); } - (TMakeIndexSequence()); + (TMakeIndexSequence()); } - constexpr void Swap(TTuple& InValue) requires (true && ... && (CMoveConstructible&& CSwappable)) + constexpr void Swap(TTuple& InValue) requires (true && ... && (CMoveConstructible&& CSwappable)) { [&A = *this, &B = InValue](TIndexSequence) { ((NAMESPACE_REDCRAFT::Swap(A.template GetValue(), B.template GetValue())), ...); } - (TMakeIndexSequence()); + (TMakeIndexSequence()); } }; -template -TTuple(Types...) -> TTuple; +template +TTuple(Ts...) -> TTuple; template using TPair = TTuple; -template -constexpr TTuple...> MakeTuple(Types&&... Args) +template +constexpr TTuple...> MakeTuple(Ts&&... Args) { - return TTuple...>(Forward(Args)...); + return TTuple...>(Forward(Args)...); } -template -constexpr TTuple Tie(Types&... Args) +template +constexpr TTuple Tie(Ts&... Args) { - return TTuple(Args...); + return TTuple(Args...); } -template -constexpr TTuple ForwardAsTuple(Types&&... Args) +template +constexpr TTuple ForwardAsTuple(Ts&&... Args) { - return TTuple(Forward(Args)...); + return TTuple(Forward(Args)...); } NAMESPACE_PRIVATE_BEGIN @@ -468,16 +468,16 @@ struct FTupleEndFlag { }; template struct TTupleCatResultImpl; -template -struct TTupleCatResultImpl, TTupleTypes...> +template +struct TTupleCatResultImpl, TTupleTypes...> { - using Type = typename TTupleCatResultImpl::Type; + using Type = typename TTupleCatResultImpl::Type; }; -template -struct TTupleCatResultImpl +template +struct TTupleCatResultImpl { - using Type = TTuple; + using Type = TTuple; }; template @@ -637,8 +637,8 @@ NAMESPACE_REDCRAFT_END NAMESPACE_STD_BEGIN // Support structure binding, should not be directly used -template struct tuple_size> : integral_constant>> { }; -template struct tuple_element> { using type = NAMESPACE_REDCRAFT::TTupleElement>; }; +template struct tuple_size> : integral_constant>> { }; +template struct tuple_element> { using type = NAMESPACE_REDCRAFT::TTupleElement>; }; NAMESPACE_STD_END @@ -647,14 +647,14 @@ NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) // Support structure binding, should not be directly used -template constexpr decltype(auto) get( TTuple& InValue) { return static_cast< TTuple& >(InValue).template GetValue(); } -template constexpr decltype(auto) get(const TTuple& InValue) { return static_cast& >(InValue).template GetValue(); } -template constexpr decltype(auto) get( volatile TTuple& InValue) { return static_cast< volatile TTuple& >(InValue).template GetValue(); } -template constexpr decltype(auto) get(const volatile TTuple& InValue) { return static_cast& >(InValue).template GetValue(); } -template constexpr decltype(auto) get( TTuple&& InValue) { return static_cast< TTuple&&>(InValue).template GetValue(); } -template constexpr decltype(auto) get(const TTuple&& InValue) { return static_cast&&>(InValue).template GetValue(); } -template constexpr decltype(auto) get( volatile TTuple&& InValue) { return static_cast< volatile TTuple&&>(InValue).template GetValue(); } -template constexpr decltype(auto) get(const volatile TTuple&& InValue) { return static_cast&&>(InValue).template GetValue(); } +template constexpr decltype(auto) get( TTuple& InValue) { return static_cast< TTuple& >(InValue).template GetValue(); } +template constexpr decltype(auto) get(const TTuple& InValue) { return static_cast& >(InValue).template GetValue(); } +template constexpr decltype(auto) get( volatile TTuple& InValue) { return static_cast< volatile TTuple& >(InValue).template GetValue(); } +template constexpr decltype(auto) get(const volatile TTuple& InValue) { return static_cast& >(InValue).template GetValue(); } +template constexpr decltype(auto) get( TTuple&& InValue) { return static_cast< TTuple&&>(InValue).template GetValue(); } +template constexpr decltype(auto) get(const TTuple&& InValue) { return static_cast&&>(InValue).template GetValue(); } +template constexpr decltype(auto) get( volatile TTuple&& InValue) { return static_cast< volatile TTuple&&>(InValue).template GetValue(); } +template constexpr decltype(auto) get(const volatile TTuple&& InValue) { return static_cast&&>(InValue).template GetValue(); } NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) diff --git a/Redcraft.Utility/Source/Public/Templates/TypeHash.h b/Redcraft.Utility/Source/Public/Templates/TypeHash.h index 81bf25b..051512a 100644 --- a/Redcraft.Utility/Source/Public/Templates/TypeHash.h +++ b/Redcraft.Utility/Source/Public/Templates/TypeHash.h @@ -39,8 +39,8 @@ constexpr size_t HashCombine(size_t A, size_t C) return C; } -template requires (true && ... && CConvertibleTo) -constexpr size_t HashCombine(size_t A, size_t C, Types... InOther) +template requires (true && ... && CConvertibleTo) +constexpr size_t HashCombine(size_t A, size_t C, Ts... InOther) { size_t B = HashCombine(A, C); return HashCombine(B, InOther...); diff --git a/Redcraft.Utility/Source/Public/Templates/Variant.h b/Redcraft.Utility/Source/Public/Templates/Variant.h index 7b07d63..293063e 100644 --- a/Redcraft.Utility/Source/Public/Templates/Variant.h +++ b/Redcraft.Utility/Source/Public/Templates/Variant.h @@ -13,92 +13,92 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -template requires (true && ... && CDestructible) +template requires (true && ... && CDestructible) class TVariant; NAMESPACE_PRIVATE_BEGIN template struct TIsTVariant : FFalse { }; -template struct TIsTVariant> : FTrue { }; +template struct TIsTVariant> : FTrue { }; template struct TVariantNumImpl; -template -struct TVariantNumImpl> : TConstant { }; +template +struct TVariantNumImpl> : TConstant { }; -template -struct TVariantNumImpl> : TConstant { }; +template +struct TVariantNumImpl> : TConstant { }; -template -struct TVariantNumImpl> : TConstant { }; +template +struct TVariantNumImpl> : TConstant { }; -template -struct TVariantNumImpl> : TConstant { }; +template +struct TVariantNumImpl> : TConstant { }; template struct TVariantIndexImpl; -template -struct TVariantIndexImpl> : TConstant>::Value + 1> +template +struct TVariantIndexImpl> : TConstant>::Value + 1> { - static_assert(sizeof...(Types) != 0, "Non-existent types in variant"); + static_assert(sizeof...(Ts) != 0, "Non-existent types in variant"); }; -template -struct TVariantIndexImpl> : TConstant +template +struct TVariantIndexImpl> : TConstant { - static_assert((true && ... && !CSameAs), "Duplicate type in variant"); + static_assert((true && ... && !CSameAs), "Duplicate type in variant"); }; template struct TVariantIndexImpl> : TConstant { }; -template -struct TVariantIndexImpl> : TVariantIndexImpl> { }; +template +struct TVariantIndexImpl> : TVariantIndexImpl> { }; -template -struct TVariantIndexImpl> : TVariantIndexImpl> { }; +template +struct TVariantIndexImpl> : TVariantIndexImpl> { }; -template -struct TVariantIndexImpl> : TVariantIndexImpl> { }; +template +struct TVariantIndexImpl> : TVariantIndexImpl> { }; template struct TVariantAlternativeImpl; -template -struct TVariantAlternativeImpl> +template +struct TVariantAlternativeImpl> { - static_assert(I < sizeof...(Types) + 1, "Invalid index in variant"); - using Type = TVariantAlternativeImpl>::Type; + static_assert(I < sizeof...(Ts) + 1, "Invalid index in variant"); + using Type = TVariantAlternativeImpl>::Type; }; -template -struct TVariantAlternativeImpl<0, TVariant> { using Type = T; }; +template +struct TVariantAlternativeImpl<0, TVariant> { using Type = T; }; -template -struct TVariantAlternativeImpl> { }; +template +struct TVariantAlternativeImpl> { }; template <> struct TVariantAlternativeImpl<0, TVariant<>> { }; -template -struct TVariantAlternativeImpl> { using Type = TAddConst>::Type>; }; +template +struct TVariantAlternativeImpl> { using Type = TAddConst>::Type>; }; -template -struct TVariantAlternativeImpl> { using Type = TAddVolatile>::Type>; }; +template +struct TVariantAlternativeImpl> { using Type = TAddVolatile>::Type>; }; -template -struct TVariantAlternativeImpl> { using Type = TAddCV>::Type>; }; +template +struct TVariantAlternativeImpl> { using Type = TAddCV>::Type>; }; -template +template struct TVariantSelectedType; -template -struct TVariantSelectedType +template +struct TVariantSelectedType { using TypeAlternativeA = TConditional, U, void>; - using TypeAlternativeB = typename TVariantSelectedType::Type; + using TypeAlternativeB = typename TVariantSelectedType::Type; using Type = TConditional, void>, TypeAlternativeB, TConditional, void>, TypeAlternativeA, @@ -138,7 +138,7 @@ inline constexpr size_t TVariantIndex = NAMESPACE_PRIVATE::TVariantIndexImpl using TVariantAlternative = typename NAMESPACE_PRIVATE::TVariantAlternativeImpl::Type; -template requires (true && ... && CDestructible) +template requires (true && ... && CDestructible) class TVariant { public: @@ -147,44 +147,44 @@ public: constexpr TVariant(FInvalid) : TVariant() { }; - constexpr TVariant(const TVariant& InValue) requires (true && ... && CCopyConstructible) + constexpr TVariant(const TVariant& InValue) requires (true && ... && CCopyConstructible) : 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 && ... && CMoveConstructible) : TypeIndex(static_cast(InValue.GetIndex())) { if (IsValid()) MoveConstructImpl[InValue.GetIndex()](&Value, &InValue.Value); } - template requires (I < sizeof...(Types)) - && CConstructibleFrom>, ArgTypes...> + template requires (I < sizeof...(Ts)) + && CConstructibleFrom>, ArgTypes...> constexpr explicit TVariant(TInPlaceIndex, ArgTypes&&... Args) : TypeIndex(I) { - using SelectedType = TVariantAlternative>; + using SelectedType = TVariantAlternative>; new(&Value) SelectedType(Forward(Args)...); } template requires CConstructibleFrom constexpr explicit TVariant(TInPlaceType, ArgTypes&&... Args) - : TVariant(InPlaceIndex>>, Forward(Args)...) + : TVariant(InPlaceIndex>>, Forward(Args)...) { } - template requires NAMESPACE_PRIVATE::TVariantSelectedType, Types...>::Value + template requires NAMESPACE_PRIVATE::TVariantSelectedType, Ts...>::Value && (!CTInPlaceType>) && (!CTInPlaceIndex>) && (!CSameAs, TVariant>) - constexpr TVariant(T&& InValue) : TVariant(InPlaceType, Types...>::Type>, Forward(InValue)) + constexpr TVariant(T&& InValue) : TVariant(InPlaceType, Ts...>::Type>, Forward(InValue)) { } constexpr ~TVariant() { - if constexpr (!(true && ... && CTriviallyDestructible)) Reset(); + if constexpr (!(true && ... && CTriviallyDestructible)) Reset(); } - constexpr TVariant& operator=(const TVariant& InValue) requires (true && ... && (CCopyConstructible && CCopyAssignable)) + constexpr TVariant& operator=(const TVariant& InValue) requires (true && ... && (CCopyConstructible && CCopyAssignable)) { if (&InValue == this) return *this; @@ -205,7 +205,7 @@ public: return *this; } - constexpr TVariant& operator=(TVariant&& InValue) requires (true && ... && (CMoveConstructible && CMoveAssignable)) + constexpr TVariant& operator=(TVariant&& InValue) requires (true && ... && (CMoveConstructible && CMoveAssignable)) { if (&InValue == this) return *this; @@ -226,29 +226,29 @@ public: return *this; } - template requires NAMESPACE_PRIVATE::TVariantSelectedType, Types...>::Value + template requires NAMESPACE_PRIVATE::TVariantSelectedType, Ts...>::Value constexpr TVariant& operator=(T&& InValue) { - using SelectedType = typename NAMESPACE_PRIVATE::TVariantSelectedType, Types...>::Type; + using SelectedType = typename NAMESPACE_PRIVATE::TVariantSelectedType, Ts...>::Type; - if (GetIndex() == TVariantIndex>) GetValue() = Forward(InValue); + if (GetIndex() == TVariantIndex>) GetValue() = Forward(InValue); else { Reset(); new(&Value) SelectedType(Forward(InValue)); - TypeIndex = TVariantIndex>; + TypeIndex = TVariantIndex>; } return *this; } - template requires (I < sizeof...(Types)) - && CConstructibleFrom>, ArgTypes...> - constexpr TVariantAlternative>& Emplace(ArgTypes&&... Args) + template requires (I < sizeof...(Ts)) + && CConstructibleFrom>, ArgTypes...> + constexpr TVariantAlternative>& Emplace(ArgTypes&&... Args) { Reset(); - using SelectedType = TVariantAlternative>; + using SelectedType = TVariantAlternative>; SelectedType* Result = new(&Value) SelectedType(Forward(Args)...); TypeIndex = I; @@ -258,7 +258,7 @@ public: template requires CConstructibleFrom constexpr T& Emplace(ArgTypes&&... Args) { - return Emplace>>(Forward(Args)...); + return Emplace>>(Forward(Args)...); } constexpr const type_info& GetTypeInfo() const { return IsValid() ? *TypeInfos[GetIndex()] : typeid(void); } @@ -268,93 +268,93 @@ public: constexpr explicit operator bool() const { return TypeIndex != 0xFF; } template constexpr bool HoldsAlternative() const { return IsValid() ? GetIndex() == I : false; } - template constexpr bool HoldsAlternative() const { return IsValid() ? GetIndex() == TVariantIndex> : false; } + template constexpr bool HoldsAlternative() const { return IsValid() ? GetIndex() == TVariantIndex> : false; } - template requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() & { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast< TVariantAlternative>*>(&Value); } - template requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() && { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast< TVariantAlternative>*>(&Value)); } - template requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() const& { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast>*>(&Value); } - template requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() const&& { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast>*>(&Value)); } + template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() & { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast< TVariantAlternative>*>(&Value); } + template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() && { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast< TVariantAlternative>*>(&Value)); } + template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const& { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast>*>(&Value); } + template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const&& { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast>*>(&Value)); } template constexpr decltype(auto) GetValue() & { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast< T*>(&Value); } template constexpr decltype(auto) GetValue() && { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast< T*>(&Value)); } template constexpr decltype(auto) GetValue() const& { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast(&Value); } template constexpr decltype(auto) GetValue() const&& { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast(&Value)); } - template requires (I < sizeof...(Types)) constexpr decltype(auto) Get( TVariantAlternative>& DefaultValue) & { return HoldsAlternative() ? GetValue() : DefaultValue; } - template requires (I < sizeof...(Types)) constexpr decltype(auto) Get(const TVariantAlternative>& DefaultValue) const& { return HoldsAlternative() ? GetValue() : DefaultValue; } + template requires (I < sizeof...(Ts)) constexpr decltype(auto) Get( TVariantAlternative>& DefaultValue) & { return HoldsAlternative() ? GetValue() : DefaultValue; } + template requires (I < sizeof...(Ts)) constexpr decltype(auto) Get(const TVariantAlternative>& DefaultValue) const& { return HoldsAlternative() ? GetValue() : DefaultValue; } template constexpr decltype(auto) Get( T& DefaultValue) & { return HoldsAlternative() ? GetValue() : DefaultValue; } template constexpr decltype(auto) Get(const T& DefaultValue) const& { return HoldsAlternative() ? GetValue() : DefaultValue; } - template requires (true && ... && CInvocable) + template requires (true && ... && CInvocable) FORCEINLINE decltype(auto) Visit(F&& Func) & { checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid().")); - using ReturnType = TCommonType...>; + using ReturnType = TCommonType...>; using FInvokeImpl = ReturnType(*)(F&&, void*); - static constexpr FInvokeImpl InvokeImpl[] = { [](F&& Func, void* This) -> ReturnType { return InvokeResult(Forward(Func), *reinterpret_cast(This)); }... }; + static constexpr FInvokeImpl InvokeImpl[] = { [](F&& Func, void* This) -> ReturnType { return InvokeResult(Forward(Func), *reinterpret_cast(This)); }... }; return InvokeImpl[GetIndex()](Forward(Func), &Value); } - template requires (true && ... && CInvocable) + template requires (true && ... && CInvocable) FORCEINLINE decltype(auto) Visit(F&& Func) && { checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid().")); - using ReturnType = TCommonType...>; + using ReturnType = TCommonType...>; using FInvokeImpl = ReturnType(*)(F&&, void*); - static constexpr FInvokeImpl InvokeImpl[] = { [](F&& Func, void* This) -> ReturnType { return InvokeResult(Forward(Func), MoveTemp(*reinterpret_cast(This))); }... }; + static constexpr FInvokeImpl InvokeImpl[] = { [](F&& Func, void* This) -> ReturnType { return InvokeResult(Forward(Func), MoveTemp(*reinterpret_cast(This))); }... }; return InvokeImpl[GetIndex()](Forward(Func), &Value); } - template requires (true && ... && CInvocable) + template requires (true && ... && CInvocable) FORCEINLINE decltype(auto) Visit(F&& Func) const& { checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid().")); - using ReturnType = TCommonType...>; + using ReturnType = TCommonType...>; using FInvokeImpl = ReturnType(*)(F&&, const void*); - static constexpr FInvokeImpl InvokeImpl[] = { [](F&& Func, const void* This) -> ReturnType { return InvokeResult(Forward(Func), *reinterpret_cast(This)); }... }; + static constexpr FInvokeImpl InvokeImpl[] = { [](F&& Func, const void* This) -> ReturnType { return InvokeResult(Forward(Func), *reinterpret_cast(This)); }... }; return InvokeImpl[GetIndex()](Forward(Func), &Value); } - template requires (true && ... && CInvocable) + template requires (true && ... && CInvocable) FORCEINLINE decltype(auto) Visit(F&& Func) const&& { checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid().")); - using ReturnType = TCommonType...>; + using ReturnType = TCommonType...>; using FInvokeImpl = ReturnType(*)(F&&, const void*); - static constexpr FInvokeImpl InvokeImpl[] = { [](F&& Func, const void* This) -> ReturnType { return InvokeResult(Forward(Func), MoveTemp(*reinterpret_cast(This))); }... }; + static constexpr FInvokeImpl InvokeImpl[] = { [](F&& Func, const void* This) -> ReturnType { return InvokeResult(Forward(Func), MoveTemp(*reinterpret_cast(This))); }... }; return InvokeImpl[GetIndex()](Forward(Func), &Value); } - template requires (true && ... && CInvocableResult) + template requires (true && ... && CInvocableResult) FORCEINLINE R Visit(F&& Func) & { return Visit(Forward(Func)); } - template requires (true && ... && CInvocableResult) + template requires (true && ... && CInvocableResult) FORCEINLINE R Visit(F&& Func) && { return MoveTemp(*this).Visit(Forward(Func)); } - template requires (true && ... && CInvocableResult) + template requires (true && ... && CInvocableResult) FORCEINLINE R Visit(F&& Func) const& { return Visit(Forward(Func)); } - template requires (true && ... && CInvocableResult) + template requires (true && ... && CInvocableResult) FORCEINLINE R Visit(F&& Func) const&& { return MoveTemp(*this).Visit(Forward(Func)); } constexpr void Reset() { if (GetIndex() == INDEX_NONE) return; - if constexpr (!(true && ... && CTriviallyDestructible)) + if constexpr (!(true && ... && CTriviallyDestructible)) { DestroyImpl[GetIndex()](&Value); } @@ -362,19 +362,19 @@ public: TypeIndex = static_cast(INDEX_NONE); } - constexpr size_t GetTypeHash() const requires (true && ... && CHashable) + constexpr size_t GetTypeHash() const requires (true && ... && CHashable) { if (!IsValid()) return 114514; using NAMESPACE_REDCRAFT::GetTypeHash; using FHashImpl = size_t(*)(const void*); - constexpr FHashImpl HashImpl[] = { [](const void* This) -> size_t { return GetTypeHash(*reinterpret_cast(This)); }... }; + constexpr FHashImpl HashImpl[] = { [](const void* This) -> size_t { return GetTypeHash(*reinterpret_cast(This)); }... }; return HashCombine(GetTypeHash(GetIndex()), HashImpl[GetIndex()](&Value)); } - constexpr void Swap(TVariant& InValue) requires (true && ... && (CMoveConstructible && CSwappable)) + constexpr void Swap(TVariant& InValue) requires (true && ... && (CMoveConstructible && CSwappable)) { if (!IsValid() && !InValue.IsValid()) return; @@ -397,7 +397,7 @@ public: using NAMESPACE_REDCRAFT::Swap; using FSwapImpl = void(*)(void*, void*); - constexpr FSwapImpl SwapImpl[] = { [](void* A, void* B) { Swap(*reinterpret_cast(A), *reinterpret_cast(B)); }... }; + constexpr FSwapImpl SwapImpl[] = { [](void* A, void* B) { Swap(*reinterpret_cast(A), *reinterpret_cast(B)); }... }; SwapImpl[GetIndex()](&Value, &InValue.Value); @@ -411,7 +411,7 @@ public: private: - static constexpr const type_info* TypeInfos[] = { &typeid(Types)... }; + static constexpr const type_info* TypeInfos[] = { &typeid(Ts)... }; using FCopyConstructImpl = void(*)(void*, const void*); using FMoveConstructImpl = void(*)(void*, void*); @@ -419,47 +419,47 @@ private: using FMoveAssignImpl = void(*)(void*, void*); using FDestroyImpl = void(*)(void* ); - static constexpr FCopyConstructImpl CopyConstructImpl[] = { [](void* A, const void* B) { if constexpr (requires(Types* A, const Types* B) { Memory::CopyConstruct (A, B); }) Memory::CopyConstruct (reinterpret_cast(A), reinterpret_cast(B)); else checkf(false, TEXT("The type '%s' is not copy constructible."), typeid(Types).name()); }... }; - static constexpr FMoveConstructImpl MoveConstructImpl[] = { [](void* A, void* B) { if constexpr (requires(Types* A, Types* B) { Memory::MoveConstruct (A, B); }) Memory::MoveConstruct (reinterpret_cast(A), reinterpret_cast< Types*>(B)); else checkf(false, TEXT("The type '%s' is not move constructible."), typeid(Types).name()); }... }; - static constexpr FCopyAssignImpl CopyAssignImpl[] = { [](void* A, const void* B) { if constexpr (requires(Types* A, const Types* B) { Memory::CopyAssign (A, B); }) Memory::CopyAssign (reinterpret_cast(A), reinterpret_cast(B)); else checkf(false, TEXT("The type '%s' is not copy assignable."), typeid(Types).name()); }... }; - static constexpr FMoveAssignImpl MoveAssignImpl[] = { [](void* A, void* B) { if constexpr (requires(Types* A, Types* B) { Memory::MoveAssign (A, B); }) Memory::MoveAssign (reinterpret_cast(A), reinterpret_cast< Types*>(B)); else checkf(false, TEXT("The type '%s' is not move assignable."), typeid(Types).name()); }... }; - static constexpr FDestroyImpl DestroyImpl[] = { [](void* A ) { if constexpr (requires(Types* A ) { Memory::Destruct (A ); }) Memory::Destruct (reinterpret_cast(A) ); else checkf(false, TEXT("The type '%s' is not destructible."), typeid(Types).name()); }... }; + static constexpr FCopyConstructImpl CopyConstructImpl[] = { [](void* A, const void* B) { if constexpr (requires(Ts* A, const Ts* B) { Memory::CopyConstruct (A, B); }) Memory::CopyConstruct (reinterpret_cast(A), reinterpret_cast(B)); else checkf(false, TEXT("The type '%s' is not copy constructible."), typeid(Ts).name()); }... }; + static constexpr FMoveConstructImpl MoveConstructImpl[] = { [](void* A, void* B) { if constexpr (requires(Ts* A, Ts* B) { Memory::MoveConstruct (A, B); }) Memory::MoveConstruct (reinterpret_cast(A), reinterpret_cast< Ts*>(B)); else checkf(false, TEXT("The type '%s' is not move constructible."), typeid(Ts).name()); }... }; + static constexpr FCopyAssignImpl CopyAssignImpl[] = { [](void* A, const void* B) { if constexpr (requires(Ts* A, const Ts* B) { Memory::CopyAssign (A, B); }) Memory::CopyAssign (reinterpret_cast(A), reinterpret_cast(B)); else checkf(false, TEXT("The type '%s' is not copy assignable."), typeid(Ts).name()); }... }; + static constexpr FMoveAssignImpl MoveAssignImpl[] = { [](void* A, void* B) { if constexpr (requires(Ts* A, Ts* B) { Memory::MoveAssign (A, B); }) Memory::MoveAssign (reinterpret_cast(A), reinterpret_cast< Ts*>(B)); else checkf(false, TEXT("The type '%s' is not move assignable."), typeid(Ts).name()); }... }; + static constexpr FDestroyImpl DestroyImpl[] = { [](void* A ) { if constexpr (requires(Ts* A ) { Memory::Destruct (A ); }) Memory::Destruct (reinterpret_cast(A) ); else checkf(false, TEXT("The type '%s' is not destructible."), typeid(Ts).name()); }... }; - TAlignedUnion<1, Types...> Value; + TAlignedUnion<1, Ts...> Value; uint8 TypeIndex; - friend constexpr bool operator==(const TVariant& LHS, const TVariant& RHS) requires (true && ... && CEqualityComparable) + 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; using FCompareImpl = bool(*)(const void*, const void*); - constexpr FCompareImpl CompareImpl[] = { [](const void* LHS, const void* RHS) -> bool { return *reinterpret_cast(LHS) == *reinterpret_cast(RHS); }... }; + constexpr FCompareImpl CompareImpl[] = { [](const void* LHS, const void* RHS) -> bool { return *reinterpret_cast(LHS) == *reinterpret_cast(RHS); }... }; return CompareImpl[LHS.GetIndex()](&LHS.Value, &RHS.Value); } - friend constexpr partial_ordering operator<=>(const TVariant& LHS, const TVariant& RHS) requires (true && ... && CSynthThreeWayComparable) + friend constexpr partial_ordering operator<=>(const TVariant& LHS, const TVariant& RHS) requires (true && ... && CSynthThreeWayComparable) { if (LHS.GetIndex() != RHS.GetIndex()) return partial_ordering::unordered; if (LHS.IsValid() == false) return partial_ordering::equivalent; using FCompareImpl = partial_ordering(*)(const void*, const void*); - constexpr FCompareImpl CompareImpl[] = { [](const void* LHS, const void* RHS) -> partial_ordering { return SynthThreeWayCompare(*reinterpret_cast(LHS), *reinterpret_cast(RHS)); }...}; + constexpr FCompareImpl CompareImpl[] = { [](const void* LHS, const void* RHS) -> partial_ordering { return SynthThreeWayCompare(*reinterpret_cast(LHS), *reinterpret_cast(RHS)); }...}; return CompareImpl[LHS.GetIndex()](&LHS.Value, &RHS.Value); } }; -template requires (!CSameAs>) && CEqualityComparable -constexpr bool operator==(const TVariant& LHS, const T& RHS) +template requires (!CSameAs>) && CEqualityComparable +constexpr bool operator==(const TVariant& LHS, const T& RHS) { return LHS.template HoldsAlternative() ? LHS.template GetValue() == RHS : false; } -template -constexpr bool operator==(const TVariant& LHS, FInvalid) +template +constexpr bool operator==(const TVariant& LHS, FInvalid) { return !LHS.IsValid(); } diff --git a/Redcraft.Utility/Source/Public/TypeTraits/Common.h b/Redcraft.Utility/Source/Public/TypeTraits/Common.h index f7f8825..ee711cb 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/Common.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/Common.h @@ -24,15 +24,15 @@ NAMESPACE_PRIVATE_BEGIN template struct TCommonTypeImpl; -// If sizeof...(Types) is zero, there is no member Type +// If sizeof...(Ts) is zero, there is no member Type template <> struct TCommonTypeImpl<> { }; -// If sizeof...(Types) is one, the member Type names the same Type as TCommonType if it exists; otherwise there is no member Type +// If sizeof...(Ts) is one, the member Type names the same Type as TCommonType if it exists; otherwise there is no member Type template struct TCommonTypeImpl : TCommonTypeImpl { }; -// If sizeof...(Types) is two +// If sizeof...(Ts) is two // If applying TDecay to at least one of T and U produces a different Type, the member Type names the same Type as TCommonType, TDecay>, if it exists; if not, there is no member Type template concept CDecayed = CSameAs> && CSameAs>; @@ -65,11 +65,11 @@ struct TCommonTypeImpl { using Type = TDecay exists, the member Type denotes TCommonType, R...> if such a Type exists -template requires (requires { typename TCommonTypeImpl::Type; }) -struct TCommonTypeImpl : TCommonTypeImpl::Type, W, Types...> { }; +template requires (requires { typename TCommonTypeImpl::Type; }) +struct TCommonTypeImpl : TCommonTypeImpl::Type, W, Ts...> { }; // In all other cases, there is no member Type template @@ -99,7 +99,7 @@ struct TCommonReferenceImpl<> { }; template struct TCommonReferenceImpl { using Type = T; }; -// If sizeof...(Types) is two +// If sizeof...(Ts) is two // If T and U are both reference types, and the simple common reference Type S of T and U exists, then the member Type Type names S template concept CSimpleCommonReference = requires { typename TSimpleCommonReferenceImpl::Type; }; @@ -137,11 +137,11 @@ struct TCommonReferenceImpl : TCommonTypeImpl { }; // Otherwise, there is no member Type. -// If sizeof...(Types) is greater than two +// If sizeof...(Ts) is greater than two // If TCommonReference exists, the member Type denotes TCommonReference, R...> if such a Type exists -template requires (requires { typename TCommonReferenceImpl::Type; }) -struct TCommonReferenceImpl : TCommonReferenceImpl::Type, W, Types...> { }; +template requires (requires { typename TCommonReferenceImpl::Type; }) +struct TCommonReferenceImpl : TCommonReferenceImpl::Type, W, Ts...> { }; // In all other cases, there is no member Type. template @@ -172,19 +172,19 @@ struct TSimpleCommonReferenceImpl { }; NAMESPACE_PRIVATE_END -template using TCommonType = typename NAMESPACE_PRIVATE::TCommonTypeImpl::Type; -template using TCommonReference = typename NAMESPACE_PRIVATE::TCommonReferenceImpl::Type; +template using TCommonType = typename NAMESPACE_PRIVATE::TCommonTypeImpl::Type; +template using TCommonReference = typename NAMESPACE_PRIVATE::TCommonReferenceImpl::Type; -template +template concept CCommonReference = - requires { typename TCommonReference; } - && (true && ... && CConvertibleTo>); + requires { typename TCommonReference; } + && (true && ... && CConvertibleTo>); -template +template concept CCommonType = - requires { typename TCommonType; } - && (true && ... && CConstructibleFrom, Types&&>) - && CCommonReference && CCommonReference&, TCommonReference>; + requires { typename TCommonType; } + && (true && ... && CConstructibleFrom, Ts&&>) + && CCommonReference && CCommonReference&, TCommonReference>; NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) diff --git a/Redcraft.Utility/Source/Public/TypeTraits/Invocable.h b/Redcraft.Utility/Source/Public/TypeTraits/Invocable.h index 7f02460..77deaf7 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/Invocable.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/Invocable.h @@ -14,11 +14,11 @@ template concept CInvocableResult = N template using TInvokeResult = NAMESPACE_STD::invoke_result_t; // FIXME: The result for char(&())[2] is wrong on MSVC -template -concept CRegularInvocable = CInvocable; +template +concept CRegularInvocable = CInvocable; -template -concept CPredicate = CRegularInvocable && CBooleanTestable>; +template +concept CPredicate = CRegularInvocable && CBooleanTestable>; template concept CRelation = diff --git a/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h b/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h index 9bc3f4a..db539a8 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h @@ -52,12 +52,12 @@ template using TMakeSigned = NAMESPACE_STD::make_signed_t; template using TMakeUnsigned = NAMESPACE_STD::make_unsigned_t; template class TAlignedStorage { struct alignas(Align) { uint8 Pad[Size]; } Padding; }; -template using TAlignedUnion = TAlignedStorage::Value, NAMESPACE_PRIVATE::TMaximum::Value>; +template using TAlignedUnion = TAlignedStorage::Value, NAMESPACE_PRIVATE::TMaximum::Value>; template using TDecay = NAMESPACE_STD::decay_t; template using TEnableIf = NAMESPACE_STD::enable_if_t; template using TConditional = NAMESPACE_STD::conditional_t; template using TUnderlyingType = NAMESPACE_STD::underlying_type_t; -template using TVoid = void; +template using TVoid = void; template using TIdentity = T; NAMESPACE_MODULE_END(Utility)