From 2ce259e7cc7ec8071a35147212bfc071ed40a914 Mon Sep 17 00:00:00 2001 From: _Redstone_c_ Date: Sun, 22 May 2022 22:52:47 +0800 Subject: [PATCH] refactor(typetraits): replaces template class type traits with alias template for TypeTraits/Miscellaneous.h --- .../Private/Testing/TemplatesTesting.cpp | 2 +- .../Private/Testing/TypeTraitsTesting.cpp | 166 +++++++++--------- .../Source/Public/Miscellaneous/Compare.h | 17 +- .../Source/Public/Templates/Any.h | 40 ++--- .../Source/Public/Templates/Atomic.h | 14 +- .../Source/Public/Templates/Function.h | 92 +++++----- .../Source/Public/Templates/Invoke.h | 2 +- .../Source/Public/Templates/Optional.h | 8 +- .../Public/Templates/ReferenceWrapper.h | 4 +- .../Source/Public/Templates/Tuple.h | 18 +- .../Source/Public/Templates/TypeHash.h | 2 +- .../Source/Public/Templates/Utility.h | 8 +- .../Source/Public/Templates/Variant.h | 38 ++-- .../Source/Public/TypeTraits/Common.h | 4 +- .../Source/Public/TypeTraits/Comparable.h | 12 +- .../Source/Public/TypeTraits/Miscellaneous.h | 42 ++--- 16 files changed, 233 insertions(+), 236 deletions(-) diff --git a/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp index 91461d2..ad09e56 100644 --- a/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp @@ -270,7 +270,7 @@ void TestVariant() { using T = decltype(Arg); always_check(Arg == 10); - always_check(CConst::Type> == bIsConst); + always_check(CConst> == bIsConst); always_check(CLValueReference == bIsLValue); always_check(CRValueReference == bIsRValue); return 0; diff --git a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp index 00967d1..28b1dd2 100644 --- a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp @@ -322,108 +322,108 @@ void TestTypeTraits() always_check(!(CConvertibleTo)); always_check((CConvertibleTo)); - always_check((CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check(!(CSameAs::Type>)); + always_check((CSameAs>)); + always_check(!(CSameAs>)); + always_check(!(CSameAs>)); + always_check(!(CSameAs>)); + always_check((CSameAs>)); + always_check(!(CSameAs>)); + always_check(!(CSameAs>)); + always_check(!(CSameAs>)); - always_check((CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check(!(CSameAs::Type>)); + always_check((CSameAs>)); + always_check(!(CSameAs>)); + always_check(!(CSameAs>)); + always_check(!(CSameAs>)); + always_check(!(CSameAs>)); + always_check((CSameAs>)); + always_check(!(CSameAs>)); + always_check(!(CSameAs>)); - always_check((CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check(!(CSameAs::Type>)); + always_check((CSameAs>)); + always_check(!(CSameAs>)); + always_check(!(CSameAs>)); + always_check(!(CSameAs>)); + always_check((CSameAs>)); + always_check((CSameAs>)); + always_check((CSameAs>)); + always_check(!(CSameAs>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check(!(CSameAs::Type>)); + always_check((CSameAs>)); + always_check((CSameAs>)); + always_check(!(CSameAs>)); + always_check(!(CSameAs>)); + always_check(!(CSameAs>)); + always_check(!(CSameAs>)); + always_check(!(CSameAs>)); + always_check(!(CSameAs>)); - always_check((CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check(!(CSameAs::Type>)); + always_check((CSameAs>)); + always_check(!(CSameAs>)); + always_check((CSameAs>)); + always_check((CSameAs>)); + always_check(!(CSameAs>)); + always_check(!(CSameAs>)); + always_check(!(CSameAs>)); + always_check(!(CSameAs>)); - always_check((CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); + always_check((CSameAs>)); + always_check(!(CSameAs>)); + always_check((CSameAs>)); + always_check((CSameAs>)); + always_check((CSameAs>)); + always_check((CSameAs>)); + always_check((CSameAs>)); + always_check((CSameAs>)); - always_check((CSameAs::Type>)); - always_check(!(CSameAs::Type>)); - always_check((CSameAs::Type>)); + always_check((CSameAs>)); + always_check(!(CSameAs>)); + always_check((CSameAs>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); + always_check((CSameAs>)); + always_check((CSameAs>)); + always_check((CSameAs>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); + always_check((CSameAs>)); + always_check((CSameAs>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); + always_check((CSameAs>)); + always_check((CSameAs>)); - TAlignedStorage<32, 4>::Type Aligned4; - TAlignedStorage<32, 8>::Type Aligned8; - TAlignedStorage<32, 16>::Type Aligned16; - TAlignedStorage<32, 32>::Type Aligned32; + TAlignedStorage<32, 4> Aligned4; + TAlignedStorage<32, 8> Aligned8; + TAlignedStorage<32, 16> Aligned16; + TAlignedStorage<32, 32> Aligned32; always_check((int64)(&Aligned4) % 4 == 0); always_check((int64)(&Aligned8) % 8 == 0); always_check((int64)(&Aligned16) % 16 == 0); always_check((int64)(&Aligned32) % 32 == 0); - always_check(sizeof(TAlignedUnion<8, int32, int32>::Type) == 8); - always_check(sizeof(TAlignedUnion<0, int8, int32>::Type) == 4); - always_check(sizeof(TAlignedUnion<0, int32, int64>::Type) == 8); - always_check(sizeof(TAlignedUnion<0, int32, double>::Type) == 8); + always_check(sizeof(TAlignedUnion<8, int32, int32>) == 8); + always_check(sizeof(TAlignedUnion<0, int8, int32>) == 4); + always_check(sizeof(TAlignedUnion<0, int32, int64>) == 8); + always_check(sizeof(TAlignedUnion<0, int32, double>) == 8); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); + always_check((CSameAs>)); + always_check((CSameAs>)); + always_check((CSameAs>)); + always_check((CSameAs>)); + always_check((CSameAs>)); + always_check((CSameAs>)); + always_check((CSameAs>)); + always_check((CSameAs>)); + always_check((CSameAs>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); + always_check((CSameAs>)); + always_check((CSameAs>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); + always_check((CSameAs>)); + always_check((CSameAs>)); + always_check((CSameAs>)); + always_check((CSameAs>)); - always_check((CSameAs::Type>)); - always_check((CSameAs::Type>)); + always_check((CSameAs>)); + always_check((CSameAs>)); // Invocable.h diff --git a/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h b/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h index 3c119af..f8b6787 100644 --- a/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h +++ b/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h @@ -42,9 +42,9 @@ concept CThreeWayComparesAs = CSameAs concept CThreeWayComparable = CWeaklyEqualityComparable && CPartiallyOrdered - && CCommonReference::Type&, const typename TRemoveReference::Type&> - && requires(const typename TRemoveReference::Type& A, const typename TRemoveReference::Type& B, - const typename TRemoveReference::Type&, const typename TRemoveReference::Type&>::Type>::Type& C) + && CCommonReference&, const TRemoveReference&> + && requires(const TRemoveReference& A, const TRemoveReference& B, + const TRemoveReference&, const TRemoveReference&>::Type>& C) { { A <=> A } -> CThreeWayComparesAs; { B <=> B } -> CThreeWayComparesAs; @@ -53,13 +53,10 @@ concept CThreeWayComparable = CWeaklyEqualityComparable && CPartiallyOrder { C <=> C } -> CThreeWayComparesAs; }; -template -struct TCompareThreeWayResult { }; - -template requires CThreeWayComparable -struct TCompareThreeWayResult +template requires CThreeWayComparable +struct TCompareThreeWayResult { - using Type = decltype(DeclVal::Type&>() <=> DeclVal::Type&>()); + using Type = decltype(DeclVal&>() <=> DeclVal&>()); }; template @@ -81,7 +78,7 @@ constexpr decltype(auto) SynthThreeWayCompare(T&& LHS, U&& RHS) template struct TSynthThreeWayResult { - using Type = decltype(SynthThreeWayCompare(DeclVal::Type&>(), DeclVal::Type&>())); + using Type = decltype(SynthThreeWayCompare(DeclVal&>(), DeclVal&>())); }; NAMESPACE_MODULE_END(Utility) diff --git a/Redcraft.Utility/Source/Public/Templates/Any.h b/Redcraft.Utility/Source/Public/Templates/Any.h index 6fe1989..2c94462 100644 --- a/Redcraft.Utility/Source/Public/Templates/Any.h +++ b/Redcraft.Utility/Source/Public/Templates/Any.h @@ -68,17 +68,17 @@ struct alignas(InlineAlignment) TAny } } - template requires CDestructible::Type> - && CConstructibleFrom::Type, Types...> + template requires CDestructible> + && CConstructibleFrom, Types...> FORCEINLINE explicit TAny(TInPlaceType, Types&&... Args) { - using SelectedType = typename TDecay::Type; + using SelectedType = TDecay; EmplaceImpl(Forward(Args)...); } - template requires (!CSameAs::Type, TAny>) && (!CTInPlaceType::Type>) - && CDestructible::Type> && CConstructibleFrom::Type, T&&> - FORCEINLINE TAny(T&& InValue) : TAny(InPlaceType::Type>, Forward(InValue)) + template requires (!CSameAs, TAny>) && (!CTInPlaceType>) + && CDestructible> && CConstructibleFrom, T&&> + FORCEINLINE TAny(T&& InValue) : TAny(InPlaceType>, Forward(InValue)) { } FORCEINLINE ~TAny() @@ -184,11 +184,11 @@ struct alignas(InlineAlignment) TAny return *this; } - template requires (!CSameAs::Type, TAny>) && (!CTInPlaceType::Type>) - && CDestructible::Type> && CConstructibleFrom::Type, T&&> + template requires (!CSameAs, TAny>) && (!CTInPlaceType>) + && CDestructible> && CConstructibleFrom, T&&> FORCEINLINE TAny& operator=(T&& InValue) { - using SelectedType = typename TDecay::Type; + using SelectedType = TDecay; if (HoldsAlternative()) { @@ -203,13 +203,13 @@ struct alignas(InlineAlignment) TAny return *this; } - template requires CDestructible::Type> - && CConstructibleFrom::Type, T&&> - FORCEINLINE typename TDecay::Type& Emplace(Types&&... Args) + template requires CDestructible> + && CConstructibleFrom, T&&> + FORCEINLINE TDecay& Emplace(Types&&... Args) { ResetImpl(); - using SelectedType = typename TDecay::Type; + using SelectedType = TDecay; EmplaceImpl(Forward(Args)...); return GetValue(); } @@ -221,22 +221,22 @@ struct alignas(InlineAlignment) TAny template constexpr bool HoldsAlternative() const { return IsValid() ? GetTypeInfo() == typeid(T) : false; } - template requires CDestructible::Type> + template requires CDestructible> constexpr T& GetValue() & { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TAny. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast< T*>(GetAllocation()); } - template requires CDestructible::Type> + template requires CDestructible> constexpr T&& GetValue() && { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TAny. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast< T*>(GetAllocation())); } - template requires CDestructible::Type> + template requires CDestructible> constexpr const T& GetValue() const& { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TAny. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast(GetAllocation()); } - template requires CDestructible::Type> + template requires CDestructible> constexpr const T&& GetValue() const&& { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TAny. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast(GetAllocation())); } - template requires CSameAs::Type>&& CDestructible::Type> + template requires CSameAs>&& CDestructible> constexpr T& Get( T& DefaultValue) & { return HoldsAlternative() ? GetValue() : DefaultValue; } - template requires CSameAs::Type>&& CDestructible::Type> + template requires CSameAs>&& CDestructible> constexpr const T& Get(const T& DefaultValue) const& { return HoldsAlternative() ? GetValue() : DefaultValue; } FORCEINLINE void Reset() @@ -345,7 +345,7 @@ private: union { - TAlignedStorage::Type InlineAllocation; + TAlignedStorage InlineAllocation; void* HeapAllocation; }; diff --git a/Redcraft.Utility/Source/Public/Templates/Atomic.h b/Redcraft.Utility/Source/Public/Templates/Atomic.h index a14e67c..7145813 100644 --- a/Redcraft.Utility/Source/Public/Templates/Atomic.h +++ b/Redcraft.Utility/Source/Public/Templates/Atomic.h @@ -15,12 +15,12 @@ NAMESPACE_MODULE_BEGIN(Utility) enum class EMemoryOrder : uint8 { - Relaxed = static_cast::Type>(NAMESPACE_STD::memory_order_relaxed), - Consume = static_cast::Type>(NAMESPACE_STD::memory_order_consume), - Acquire = static_cast::Type>(NAMESPACE_STD::memory_order_acquire), - Release = static_cast::Type>(NAMESPACE_STD::memory_order_release), - AcquireRelease = static_cast::Type>(NAMESPACE_STD::memory_order_acq_rel), - SequentiallyConsistent = static_cast::Type>(NAMESPACE_STD::memory_order_seq_cst), + Relaxed = static_cast>(NAMESPACE_STD::memory_order_relaxed), + Consume = static_cast>(NAMESPACE_STD::memory_order_consume), + Acquire = static_cast>(NAMESPACE_STD::memory_order_acquire), + Release = static_cast>(NAMESPACE_STD::memory_order_release), + AcquireRelease = static_cast>(NAMESPACE_STD::memory_order_acq_rel), + SequentiallyConsistent = static_cast>(NAMESPACE_STD::memory_order_seq_cst), }; #if BUILD_DEBUG @@ -58,7 +58,7 @@ struct TAtomic : public FSingleton { protected: - using ElementType = typename TConditional, NAMESPACE_STD::atomic>::Type; + using ElementType = TConditional, NAMESPACE_STD::atomic>; public: diff --git a/Redcraft.Utility/Source/Public/Templates/Function.h b/Redcraft.Utility/Source/Public/Templates/Function.h index 94c712d..0d3084c 100644 --- a/Redcraft.Utility/Source/Public/Templates/Function.h +++ b/Redcraft.Utility/Source/Public/Templates/Function.h @@ -115,10 +115,10 @@ public: FORCEINLINE const type_info& TargetType() const requires (!bIsRef) { return IsValid() ? Storage.GetTypeInfo() : typeid(void); }; - template FORCEINLINE T& Target() & requires (!bIsRef) && CDestructible::Type> { return static_cast< StorageType& >(Storage).template GetValue(); } - template FORCEINLINE T&& Target() && requires (!bIsRef) && CDestructible::Type> { return static_cast< StorageType&&>(Storage).template GetValue(); } - template FORCEINLINE const T& Target() const& requires (!bIsRef) && CDestructible::Type> { return static_cast(Storage).template GetValue(); } - template FORCEINLINE const T&& Target() const&& requires (!bIsRef) && CDestructible::Type> { return static_cast(Storage).template GetValue(); } + template FORCEINLINE T& Target() & requires (!bIsRef) && CDestructible> { return static_cast< StorageType& >(Storage).template GetValue(); } + template FORCEINLINE T&& Target() && requires (!bIsRef) && CDestructible> { return static_cast< StorageType&&>(Storage).template GetValue(); } + template FORCEINLINE const T& Target() const& requires (!bIsRef) && CDestructible> { return static_cast(Storage).template GetValue(); } + template FORCEINLINE const T&& Target() const&& requires (!bIsRef) && CDestructible> { return static_cast(Storage).template GetValue(); } constexpr void Swap(TFunctionImpl& InValue) requires (!bIsRef) { @@ -146,8 +146,8 @@ public: private: - using StorageType = typename TConditional::Type*, TAny>::Type; - using StorageRef = typename TConditional::Type*, typename TCopyCVRef::Type&>::Type; + using StorageType = TConditional::Type*, TAny>; + using StorageRef = TConditional::Type*, typename TCopyCVRef::Type&>; using CallFunc = ResultType(*)(StorageRef, Types&&...); @@ -171,18 +171,18 @@ protected: template FORCEINLINE void EmplaceImpl(ArgTypes&&... Args) { - using CallableType = typename TCopyConst::Type, DecayedType>::Type; + using CallableType = typename TCopyConst, DecayedType>::Type; if constexpr (bIsRef) Storage = ((reinterpret_cast(AddressOf(Args))), ...); else Storage.template Emplace(Forward(Args)...); Callable = [](StorageRef Storage, Types&&... Args) -> ResultType { - using InvokeType = typename TConditional< + using InvokeType = TConditional< CReference, typename TCopyCVRef::Type, typename TCopyCVRef::Type& - >::Type; + >; const auto GetFunc = [&Storage]() -> InvokeType { @@ -249,11 +249,11 @@ public: TFunctionRef& operator=(const TFunctionRef& InValue) = delete; TFunctionRef& operator=(TFunctionRef&& InValue) = delete; - template requires (!CTFunctionRef::Type>) && (!CTInPlaceType::Type>) - && NAMESPACE_PRIVATE::TIsInvocableSignature::Type>::Value + template requires (!CTFunctionRef>) && (!CTInPlaceType>) + && NAMESPACE_PRIVATE::TIsInvocableSignature>::Value FORCEINLINE TFunctionRef(T&& InValue) { - using DecayedType = typename TDecay::Type; + using DecayedType = TDecay; checkf(NAMESPACE_PRIVATE::FunctionIsBound(InValue), TEXT("Cannot bind a null/unbound callable to a TFunctionRef")); Super::template EmplaceImpl(Forward(InValue)); } @@ -302,33 +302,33 @@ public: return *this; } - template requires (!CTInPlaceType::Type>) - && (!CTFunctionRef::Type>) && (!CTFunction::Type>) && (!CTUniqueFunction::Type>) - && CConstructibleFrom::Type, T&&> && CCopyConstructible::Type> - && NAMESPACE_PRIVATE::TIsInvocableSignature::Type>::Value + template requires (!CTInPlaceType>) + && (!CTFunctionRef>) && (!CTFunction>) && (!CTUniqueFunction>) + && CConstructibleFrom, T&&> && CCopyConstructible> + && NAMESPACE_PRIVATE::TIsInvocableSignature>::Value FORCEINLINE TFunction(T&& InValue) { - using DecayedType = typename TDecay::Type; + using DecayedType = TDecay; if (!NAMESPACE_PRIVATE::FunctionIsBound(InValue)) Super::ResetImpl(); else Super::template EmplaceImpl(Forward(InValue)); } - template requires NAMESPACE_PRIVATE::TIsInvocableSignature::Type>::Value - && CConstructibleFrom::Type, ArgTypes...> && CCopyConstructible::Type> + template requires NAMESPACE_PRIVATE::TIsInvocableSignature>::Value + && CConstructibleFrom, ArgTypes...> && CCopyConstructible> FORCEINLINE TFunction(TInPlaceType, ArgTypes&&... Args) { - using DecayedType = typename TDecay::Type; + using DecayedType = TDecay; Super::template EmplaceImpl(Forward(Args)...); } constexpr TFunction& operator=(nullptr_t) { Super::ResetImpl(); return *this; } - template requires NAMESPACE_PRIVATE::TIsInvocableSignature::Type>::Value - && (!CTFunctionRef::Type>) && (!CTFunction::Type>) && (!CTUniqueFunction::Type>) - && CConstructibleFrom::Type, T&&> && CCopyConstructible::Type> + template requires NAMESPACE_PRIVATE::TIsInvocableSignature>::Value + && (!CTFunctionRef>) && (!CTFunction>) && (!CTUniqueFunction>) + && CConstructibleFrom, T&&> && CCopyConstructible> FORCEINLINE TFunction& operator=(T&& InValue) { - using DecayedType = typename TDecay::Type; + using DecayedType = TDecay; if (!NAMESPACE_PRIVATE::FunctionIsBound(InValue)) Super::ResetImpl(); else Super::template EmplaceImpl(Forward(InValue)); @@ -336,11 +336,11 @@ public: return *this; } - template requires NAMESPACE_PRIVATE::TIsInvocableSignature::Type>::Value - && CConstructibleFrom::Type, ArgTypes...>&& CCopyConstructible::Type> - FORCEINLINE typename TDecay::Type& Emplace(ArgTypes&&... Args) + template requires NAMESPACE_PRIVATE::TIsInvocableSignature>::Value + && CConstructibleFrom, ArgTypes...>&& CCopyConstructible> + FORCEINLINE TDecay& Emplace(ArgTypes&&... Args) { - using DecayedType = typename TDecay::Type; + using DecayedType = TDecay; Super::template EmplaceImpl(Forward(Args)...); return Super::template Target(); } @@ -405,33 +405,33 @@ public: return *this; } - template requires (!CTInPlaceType::Type>) - && (!CTFunctionRef::Type>) && (!CTFunction::Type>) && (!CTUniqueFunction::Type>) - && CConstructibleFrom::Type, T&&> && CMoveConstructible::Type> - && NAMESPACE_PRIVATE::TIsInvocableSignature::Type>::Value + template requires (!CTInPlaceType>) + && (!CTFunctionRef>) && (!CTFunction>) && (!CTUniqueFunction>) + && CConstructibleFrom, T&&> && CMoveConstructible> + && NAMESPACE_PRIVATE::TIsInvocableSignature>::Value FORCEINLINE TUniqueFunction(T&& InValue) { - using DecayedType = typename TDecay::Type; + using DecayedType = TDecay; if (!NAMESPACE_PRIVATE::FunctionIsBound(InValue)) Super::ResetImpl(); else Super::template EmplaceImpl(Forward(InValue)); } - template requires NAMESPACE_PRIVATE::TIsInvocableSignature::Type>::Value - && CConstructibleFrom::Type, ArgTypes...> && CMoveConstructible::Type> + template requires NAMESPACE_PRIVATE::TIsInvocableSignature>::Value + && CConstructibleFrom, ArgTypes...> && CMoveConstructible> FORCEINLINE TUniqueFunction(TInPlaceType, ArgTypes&&... Args) { - using DecayedType = typename TDecay::Type; + using DecayedType = TDecay; Super::template EmplaceImpl(Forward(Args)...); } constexpr TUniqueFunction& operator=(nullptr_t) { Super::ResetImpl(); return *this; } - template requires NAMESPACE_PRIVATE::TIsInvocableSignature::Type>::Value - && (!CTFunctionRef::Type>) && (!CTFunction::Type>) && (!CTUniqueFunction::Type>) - && CConstructibleFrom::Type, T&&>&& CMoveConstructible::Type> + template requires NAMESPACE_PRIVATE::TIsInvocableSignature>::Value + && (!CTFunctionRef>) && (!CTFunction>) && (!CTUniqueFunction>) + && CConstructibleFrom, T&&>&& CMoveConstructible> FORCEINLINE TUniqueFunction& operator=(T&& InValue) { - using DecayedType = typename TDecay::Type; + using DecayedType = TDecay; if (!NAMESPACE_PRIVATE::FunctionIsBound(InValue)) Super::ResetImpl(); else Super::template EmplaceImpl(Forward(InValue)); @@ -439,11 +439,11 @@ public: return *this; } - template requires NAMESPACE_PRIVATE::TIsInvocableSignature::Type>::Value - && CConstructibleFrom::Type, ArgTypes...>&& CMoveConstructible::Type> - FORCEINLINE typename TDecay::Type& Emplace(ArgTypes&&... Args) + template requires NAMESPACE_PRIVATE::TIsInvocableSignature>::Value + && CConstructibleFrom, ArgTypes...>&& CMoveConstructible> + FORCEINLINE TDecay& Emplace(ArgTypes&&... Args) { - using DecayedType = typename TDecay::Type; + using DecayedType = TDecay; Super::template EmplaceImpl(Forward(Args)...); return Super::template Target(); } @@ -518,9 +518,9 @@ struct TNotFunction NAMESPACE_PRIVATE_END template -constexpr NAMESPACE_PRIVATE::TNotFunction::Type> NotFn(F&& Func) +constexpr NAMESPACE_PRIVATE::TNotFunction> NotFn(F&& Func) { - return NAMESPACE_PRIVATE::TNotFunction::Type>(Forward(Func)); + return NAMESPACE_PRIVATE::TNotFunction>(Forward(Func)); } NAMESPACE_MODULE_END(Utility) diff --git a/Redcraft.Utility/Source/Public/Templates/Invoke.h b/Redcraft.Utility/Source/Public/Templates/Invoke.h index c3cf9ce..114110d 100644 --- a/Redcraft.Utility/Source/Public/Templates/Invoke.h +++ b/Redcraft.Utility/Source/Public/Templates/Invoke.h @@ -56,7 +56,7 @@ struct InvokeMemberObject template ::Type, + typename Decayed = TDecay, bool IsMemberFunction = CMemberFunctionPointer, bool IsMemberObject = CMemberObjectPointer> struct InvokeMember; diff --git a/Redcraft.Utility/Source/Public/Templates/Optional.h b/Redcraft.Utility/Source/Public/Templates/Optional.h index 3853bab..77681cb 100644 --- a/Redcraft.Utility/Source/Public/Templates/Optional.h +++ b/Redcraft.Utility/Source/Public/Templates/Optional.h @@ -48,7 +48,7 @@ public: } template requires CConstructibleFrom - && (!CSameAs::Type, FInPlace>) && (!CSameAs::Type, TOptional>) + && (!CSameAs, FInPlace>) && (!CSameAs, TOptional>) constexpr explicit (!CConvertibleTo) TOptional(T&& InValue) : TOptional(InPlace, Forward(InValue)) { } @@ -246,7 +246,7 @@ public: private: - TAlignedStorage::Type Value; + TAlignedStorage Value; bool bIsValid; }; @@ -283,9 +283,9 @@ constexpr bool operator==(const TOptional& LHS, FInvalid) } template requires CDestructible -constexpr TOptional::Type> MakeOptional(FInvalid) +constexpr TOptional> MakeOptional(FInvalid) { - return TOptional::Type>(Invalid); + return TOptional>(Invalid); } template requires CDestructible && CConstructibleFrom diff --git a/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h b/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h index 9045462..5a4fa70 100644 --- a/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h +++ b/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h @@ -111,7 +111,7 @@ template concept CTReferenceWrapper = NAMESPACE_PRIVATE::TIsTRefere template struct TUnwrapReference { using Type = T; }; template struct TUnwrapReference> { using Type = T&; }; -template struct TUnwrapRefDecay { using Type = typename TUnwrapReference::Type>::Type; }; +template struct TUnwrapRefDecay { using Type = typename TUnwrapReference>::Type; }; template struct TOptional> @@ -150,7 +150,7 @@ public: { } template requires CConstructibleFrom - && (!CSameAs::Type, FInPlace>) && (!CSameAs::Type, TOptional>) + && (!CSameAs, FInPlace>) && (!CSameAs, TOptional>) constexpr explicit (!CConvertibleTo) TOptional(T&& InValue) : TOptional(InPlace, Forward(InValue)) { } diff --git a/Redcraft.Utility/Source/Public/Templates/Tuple.h b/Redcraft.Utility/Source/Public/Templates/Tuple.h index f18ea84..e1252b7 100644 --- a/Redcraft.Utility/Source/Public/Templates/Tuple.h +++ b/Redcraft.Utility/Source/Public/Templates/Tuple.h @@ -401,13 +401,13 @@ NAMESPACE_PRIVATE_END template concept CTTuple = NAMESPACE_PRIVATE::TIsTTuple::Value; -template requires CTTuple::Type> -struct TTupleElementSize : TConstant::Type::ElementSize> { }; +template requires CTTuple> +struct TTupleElementSize : TConstant::ElementSize> { }; -template requires CTTuple::Type> -struct TTupleElementType { using Type = typename TCopyCVRef::Type, typename TRemoveCVRef::Type::template TElementType::Type>::Type; }; +template requires CTTuple> +struct TTupleElementType { using Type = typename TCopyCVRef, typename TRemoveCVRef::template TElementType::Type>::Type; }; -template requires CTTuple::Type> +template requires CTTuple> struct TTupleElementIndex : TupleType::template TElementIndex { }; template @@ -454,7 +454,7 @@ template struct TTupleCatMake, TIndexSequence> { template - struct ForwardType { using Type = typename TConditional, typename TRemoveReference::Type&&, U>::Type; }; + struct ForwardType { using Type = TConditional, TRemoveReference&&, U>; }; template static constexpr TTuple F(TTupleType&& InValue) @@ -546,10 +546,10 @@ struct TTupleVisitImpl> NAMESPACE_PRIVATE_END -template requires (true && ... && (CTTuple::Type>)) -struct TTupleCatResult { using Type = typename NAMESPACE_PRIVATE::TTupleCatResultImpl::Type..., NAMESPACE_PRIVATE::FTupleEndFlag>::Type; }; +template requires (true && ... && (CTTuple>)) +struct TTupleCatResult { using Type = typename NAMESPACE_PRIVATE::TTupleCatResultImpl..., NAMESPACE_PRIVATE::FTupleEndFlag>::Type; }; -template requires (true && ... && (CTTuple::Type>)) +template requires (true && ... && (CTTuple>)) constexpr auto TupleCat(TTupleTypes&&... Args) { using R = typename TTupleCatResult::Type; diff --git a/Redcraft.Utility/Source/Public/Templates/TypeHash.h b/Redcraft.Utility/Source/Public/Templates/TypeHash.h index 3150ec0..051512a 100644 --- a/Redcraft.Utility/Source/Public/Templates/TypeHash.h +++ b/Redcraft.Utility/Source/Public/Templates/TypeHash.h @@ -77,7 +77,7 @@ constexpr size_t GetTypeHash(T A) template requires CEnum constexpr size_t GetTypeHash(T A) { - return GetTypeHash(static_cast::Type>(A)); + return GetTypeHash(static_cast>(A)); } template requires CPointer || CSameAs diff --git a/Redcraft.Utility/Source/Public/Templates/Utility.h b/Redcraft.Utility/Source/Public/Templates/Utility.h index d8ad1ed..03263b8 100644 --- a/Redcraft.Utility/Source/Public/Templates/Utility.h +++ b/Redcraft.Utility/Source/Public/Templates/Utility.h @@ -25,9 +25,9 @@ constexpr const T(&AsConst(T(&Array)[N]))[N] } template -constexpr typename TRemoveReference::Type&& MoveTemp(T&& Obj) +constexpr TRemoveReference&& MoveTemp(T&& Obj) { - typedef typename TRemoveReference::Type CastType; + typedef TRemoveReference CastType; return (CastType&&)Obj; } @@ -50,13 +50,13 @@ constexpr T&& CopyTemp(T&& Val) } template -constexpr T&& Forward(typename TRemoveReference::Type& Obj) +constexpr T&& Forward(TRemoveReference& Obj) { return (T&&)Obj; } template -constexpr T&& Forward(typename TRemoveReference::Type&& Obj) +constexpr T&& Forward(TRemoveReference&& Obj) { return (T&&)Obj; } diff --git a/Redcraft.Utility/Source/Public/Templates/Variant.h b/Redcraft.Utility/Source/Public/Templates/Variant.h index a8d24e4..7e84454 100644 --- a/Redcraft.Utility/Source/Public/Templates/Variant.h +++ b/Redcraft.Utility/Source/Public/Templates/Variant.h @@ -49,21 +49,21 @@ struct TVariantSelectedType; template struct TVariantSelectedType { - using TypeAlternativeA = typename TConditional, U, void>::Type; + using TypeAlternativeA = TConditional, U, void>; using TypeAlternativeB = typename TVariantSelectedType::Type; - using Type = typename TConditional::Type, void>, TypeAlternativeB, - typename TConditional::Type, void>, TypeAlternativeA, - typename TConditional::Type, typename TRemoveCVRef::Type>, TypeAlternativeB, TypeAlternativeA>::Type>::Type>::Type; + using Type = TConditional, void>, TypeAlternativeB, + TConditional, void>, TypeAlternativeA, + TConditional, TRemoveCVRef>, TypeAlternativeB, TypeAlternativeA>>>; // 0 - Type not found // 1 - Same type found // 2 - Multiple types found // 3 - The type found - static constexpr uint8 Flag = CSameAs::Type, void> ? 0 : - CSameAs::Type, typename TRemoveCVRef::Type> ? 2 : - CSameAs::Type, typename TRemoveCVRef< T>::Type> ? 1 : - !CSameAs::Type, void> && !CSameAs ? 2 : 3; + static constexpr uint8 Flag = CSameAs, void> ? 0 : + CSameAs, TRemoveCVRef> ? 2 : + CSameAs, TRemoveCVRef< T>> ? 1 : + !CSameAs, void> && !CSameAs ? 2 : 3; static constexpr bool Value = Flag & 1; @@ -117,10 +117,10 @@ struct TVariant : TVariant(InPlaceIndex::Value>, Forward(Args)...) { } - template requires NAMESPACE_PRIVATE::TVariantSelectedType::Type, Types...>::Value - && (!CTInPlaceType::Type>) && (!CTInPlaceIndex::Type>) - && (!CSameAs::Type, TVariant>) - constexpr TVariant(T&& InValue) : TVariant(InPlaceType::Type, Types...>::Type>, Forward(InValue)) + template requires NAMESPACE_PRIVATE::TVariantSelectedType, Types...>::Value + && (!CTInPlaceType>) && (!CTInPlaceIndex>) + && (!CSameAs, TVariant>) + constexpr TVariant(T&& InValue) : TVariant(InPlaceType, Types...>::Type>, Forward(InValue)) { } constexpr ~TVariant() @@ -170,10 +170,10 @@ struct TVariant return *this; } - template requires NAMESPACE_PRIVATE::TVariantSelectedType::Type, Types...>::Value + template requires NAMESPACE_PRIVATE::TVariantSelectedType, Types...>::Value constexpr TVariant& operator=(T&& InValue) { - using SelectedType = typename NAMESPACE_PRIVATE::TVariantSelectedType::Type, Types...>::Type; + using SelectedType = typename NAMESPACE_PRIVATE::TVariantSelectedType, Types...>::Type; if (GetIndex() == TAlternativeIndex::Value) GetValue() = Forward(InValue); else @@ -370,7 +370,7 @@ private: 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()); }... }; - TAlignedUnion<1, Types...>::Type Value; + TAlignedUnion<1, Types...> Value; uint8 TypeIndex; friend constexpr bool operator==(const TVariant& LHS, const TVariant& RHS) requires (true && ... && CEqualityComparable) @@ -418,13 +418,13 @@ NAMESPACE_PRIVATE_END template concept CTVariant = NAMESPACE_PRIVATE::TIsTVariant::Value; -template requires CTVariant::Type> +template requires CTVariant> struct TVariantAlternativeSize : TConstant { }; -template requires CTVariant::Type> -struct TVariantAlternativeType { using Type = typename TCopyCV::Type, typename TRemoveCVRef::Type::template TAlternativeType::Type>::Type; }; +template requires CTVariant> +struct TVariantAlternativeType { using Type = typename TCopyCV, typename TRemoveCVRef::template TAlternativeType::Type>::Type; }; -template requires CTVariant::Type> +template requires CTVariant> struct TVariantAlternativeIndex : VariantType::template TAlternativeIndex { }; NAMESPACE_MODULE_END(Utility) diff --git a/Redcraft.Utility/Source/Public/TypeTraits/Common.h b/Redcraft.Utility/Source/Public/TypeTraits/Common.h index f07652a..ed86d7c 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/Common.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/Common.h @@ -21,8 +21,8 @@ template struct TCommonReference { using Type = NAMESPACE_ST NAMESPACE_PRIVATE_END -template struct TCommonType : TConditional, NAMESPACE_PRIVATE::TCommonType, NAMESPACE_PRIVATE::FNoopStruct>::Type { }; -template struct TCommonReference : TConditional, NAMESPACE_PRIVATE::TCommonReference, NAMESPACE_PRIVATE::FNoopStruct>::Type { }; +template struct TCommonType : TConditional, NAMESPACE_PRIVATE::TCommonType, NAMESPACE_PRIVATE::FNoopStruct> { }; +template struct TCommonReference : TConditional, NAMESPACE_PRIVATE::TCommonReference, NAMESPACE_PRIVATE::FNoopStruct> { }; template concept CCommonReference = diff --git a/Redcraft.Utility/Source/Public/TypeTraits/Comparable.h b/Redcraft.Utility/Source/Public/TypeTraits/Comparable.h index d967fc3..a019991 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/Comparable.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/Comparable.h @@ -11,7 +11,7 @@ NAMESPACE_MODULE_BEGIN(Utility) template concept CWeaklyEqualityComparable = - requires(const typename TRemoveReference::Type& A, const typename TRemoveReference::Type& B) + requires(const TRemoveReference& A, const TRemoveReference& B) { { A == B } -> CBooleanTestable; { A != B } -> CBooleanTestable; @@ -21,12 +21,12 @@ concept CWeaklyEqualityComparable = template concept CEqualityComparable = CWeaklyEqualityComparable && CWeaklyEqualityComparable && CWeaklyEqualityComparable - && CCommonReference::Type&, const typename TRemoveReference::Type&> - && CWeaklyEqualityComparable::Type&, const typename TRemoveReference::Type&>::Type>; + && CCommonReference&, const TRemoveReference&> + && CWeaklyEqualityComparable&, const TRemoveReference&>::Type>; template concept CPartiallyOrdered = - requires(const typename TRemoveReference::Type& A, const typename TRemoveReference::Type& B) + requires(const TRemoveReference& A, const TRemoveReference& B) { { A < B } -> CBooleanTestable; { A > B } -> CBooleanTestable; @@ -43,8 +43,8 @@ concept CTotallyOrdered = CPartiallyOrdered && CPartiallyOrdered && CEqualityComparable && CEqualityComparable && CPartiallyOrdered && CEqualityComparable - && CPartiallyOrdered::Type&, const typename TRemoveReference::Type&>::Type> - && CEqualityComparable::Type&, const typename TRemoveReference::Type&>::Type>; + && CPartiallyOrdered&, const TRemoveReference&>::Type> + && CEqualityComparable&, const TRemoveReference&>::Type>; NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) diff --git a/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h b/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h index 218b2cf..2b1f8d5 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h @@ -28,30 +28,30 @@ NAMESPACE_PRIVATE_END template inline constexpr size_t ArrayRank = NAMESPACE_STD::rank_v; template inline constexpr size_t ArrayExtent = NAMESPACE_STD::extent_v; -template concept CSameAs = NAMESPACE_STD::is_same_v; -template concept CBaseOf = NAMESPACE_STD::is_base_of_v; -template concept CConvertibleTo = NAMESPACE_STD::is_convertible_v; +template concept CSameAs = NAMESPACE_STD::is_same_v; +template concept CBaseOf = NAMESPACE_STD::is_base_of_v; +template concept CConvertibleTo = NAMESPACE_STD::is_convertible_v; -template struct TRemoveConst { using Type = NAMESPACE_STD::remove_const_t; }; -template struct TRemoveVolatile { using Type = NAMESPACE_STD::remove_volatile_t; }; -template struct TRemoveCV { using Type = NAMESPACE_STD::remove_cv_t; }; -template struct TRemovePointer { using Type = NAMESPACE_STD::remove_pointer_t; }; -template struct TRemoveReference { using Type = NAMESPACE_STD::remove_reference_t; }; -template struct TRemoveCVRef { using Type = NAMESPACE_STD::remove_cvref_t; }; -template struct TRemoveExtent { using Type = NAMESPACE_STD::remove_extent_t; }; -template struct TRemoveAllExtents { using Type = NAMESPACE_STD::remove_all_extents_t; }; +template using TRemoveConst = NAMESPACE_STD::remove_const_t; +template using TRemoveVolatile = NAMESPACE_STD::remove_volatile_t; +template using TRemoveCV = NAMESPACE_STD::remove_cv_t; +template using TRemovePointer = NAMESPACE_STD::remove_pointer_t; +template using TRemoveReference = NAMESPACE_STD::remove_reference_t; +template using TRemoveCVRef = NAMESPACE_STD::remove_cvref_t; +template using TRemoveExtent = NAMESPACE_STD::remove_extent_t; +template using TRemoveAllExtents = NAMESPACE_STD::remove_all_extents_t; -template struct TMakeSigned { using Type = NAMESPACE_STD::make_signed_t; }; -template struct TMakeUnsigned { using Type = NAMESPACE_STD::make_unsigned_t; }; +template using TMakeSigned = NAMESPACE_STD::make_signed_t; +template using TMakeUnsigned = NAMESPACE_STD::make_unsigned_t; -template struct TAlignedStorage { class Type { struct alignas(Align) { uint8 Pad[Size]; } Padding; }; }; -template struct TAlignedUnion { using Type = TAlignedStorage::Value, NAMESPACE_PRIVATE::TMaximum::Value>::Type; }; -template struct TDecay { using Type = NAMESPACE_STD::decay_t; }; -template struct TEnableIf { using Type = NAMESPACE_STD::enable_if_t; }; -template struct TConditional { using Type = NAMESPACE_STD::conditional_t; }; -template struct TUnderlyingType { using Type = NAMESPACE_STD::underlying_type_t; }; -template struct TVoid { using Type = void; }; -template struct TIdentity { using Type = T; }; +template class TAlignedStorage { struct alignas(Align) { uint8 Pad[Size]; } Padding; }; +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 TIdentity = T; NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft)