diff --git a/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp index 9224b50..1d222d8 100644 --- a/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp @@ -271,8 +271,8 @@ void TestVariant() using T = decltype(Arg); always_check(Arg == 10); always_check(TIsConst::Type>::Value == bIsConst); - always_check(TIsLValueReference::Value == bIsLValue); - always_check(TIsRValueReference::Value == bIsRValue); + 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 26726a1..b515e6a 100644 --- a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp @@ -64,59 +64,59 @@ void TestTypeTraits() // PrimaryType.h - always_check(!TIsVoid::Value); - always_check(TIsVoid::Value); - always_check(TIsVoid::Value); - always_check(TIsVoid::Value); - always_check(TIsVoid::Value); + always_check(!CVoid); + always_check(CVoid); + always_check(CVoid); + always_check(CVoid); + always_check(CVoid); - always_check(!TIsNullPointer::Value); - always_check(TIsNullPointer::Value); + always_check(!CNullPointer); + always_check(CNullPointer); - always_check(TIsIntegral::Value); - always_check(!TIsIntegral::Value); + always_check(CIntegral); + always_check(!CIntegral); - always_check(!TIsFloatingPoint::Value); - always_check(TIsFloatingPoint::Value); + always_check(!CFloatingPoint); + always_check(CFloatingPoint); - always_check(!TIsArray::Value); - always_check(TIsArray::Value); - always_check(TIsArray::Value); + always_check(!CArray); + always_check(CArray); + always_check(CArray); - always_check(!TIsPointer::Value); - always_check(TIsPointer::Value); + always_check(!CPointer); + always_check(CPointer); - always_check(!TIsLValueReference::Value); - always_check(TIsLValueReference::Value); - always_check(!TIsLValueReference::Value); + always_check(!CLValueReference); + always_check(CLValueReference); + always_check(!CLValueReference); - always_check(!TIsRValueReference::Value); - always_check(!TIsRValueReference::Value); - always_check(TIsRValueReference::Value); + always_check(!CRValueReference); + always_check(!CRValueReference); + always_check(CRValueReference); - always_check(TIsMemberObjectPointer::Value); - always_check(!TIsMemberObjectPointer::Value); + always_check(CMemberObjectPointer); + always_check(!CMemberObjectPointer); - always_check(!TIsMemberFunctionPointer::Value); - always_check(TIsMemberFunctionPointer::Value); + always_check(!CMemberFunctionPointer); + always_check(CMemberFunctionPointer); - always_check(!TIsEnum::Value); - always_check(!TIsEnum::Value); - always_check(TIsEnum::Value); - always_check(TIsEnum::Value); + always_check(!CEnum); + always_check(!CEnum); + always_check(CEnum); + always_check(CEnum); - always_check(!TIsUnion::Value); - always_check(!TIsUnion::Value); - always_check(TIsUnion::Value); + always_check(!CUnion); + always_check(!CUnion); + always_check(CUnion); - always_check(!TIsUnion::Value); - always_check(!TIsUnion::Value); - always_check(TIsUnion::Value); + always_check(!CUnion); + always_check(!CUnion); + always_check(CUnion); - always_check(!TIsFunction::Value); - always_check(!TIsFunction::Value); - always_check(!TIsFunction::Value); - always_check(TIsFunction::Value); + always_check(!CFunction); + always_check(!CFunction); + always_check(!CFunction); + always_check(CFunction); // CompositeType.h diff --git a/Redcraft.Utility/Source/Public/Concepts/Assignable.h b/Redcraft.Utility/Source/Public/Concepts/Assignable.h index 7ffcfd2..82baf2d 100644 --- a/Redcraft.Utility/Source/Public/Concepts/Assignable.h +++ b/Redcraft.Utility/Source/Public/Concepts/Assignable.h @@ -11,7 +11,7 @@ NAMESPACE_MODULE_BEGIN(Utility) template concept CAssignableFrom = - TIsLValueReference::Value && + CLValueReference && CCommonReferenceWith::Type&, const typename TRemoveReference::Type&> && requires(T A, U&& B) { diff --git a/Redcraft.Utility/Source/Public/Concepts/BuiltinType.h b/Redcraft.Utility/Source/Public/Concepts/BuiltinType.h index 6b6d098..18e6292 100644 --- a/Redcraft.Utility/Source/Public/Concepts/BuiltinType.h +++ b/Redcraft.Utility/Source/Public/Concepts/BuiltinType.h @@ -7,11 +7,9 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -template concept CIntegral = TIsIntegral::Value; template concept CSignedIntegral = CIntegral && TIsSigned::Value; template concept CUnsignedIntegral = CIntegral && TIsUnsigned::Value; template concept CNonBooleanIntegral = CIntegral && !TIsSame::Type, bool>::Value; -template concept CFloatingPoint = TIsFloatingPoint::Value; NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) diff --git a/Redcraft.Utility/Source/Public/Memory/Alignment.h b/Redcraft.Utility/Source/Public/Memory/Alignment.h index d55c72d..455996f 100644 --- a/Redcraft.Utility/Source/Public/Memory/Alignment.h +++ b/Redcraft.Utility/Source/Public/Memory/Alignment.h @@ -12,28 +12,28 @@ NAMESPACE_BEGIN(Memory) FORCEINLINE constexpr bool IsValidAlignment(size_t Alignment) { return !(Alignment & (Alignment - 1)); } -template requires TIsIntegral::Value || TIsPointer::Value +template requires CIntegral || CPointer FORCEINLINE constexpr T Align(T InValue, size_t Alignment) { checkf(IsValidAlignment(Alignment), TEXT("The alignment value must be an integer power of 2.")); return (T)(((uint64)(InValue) + static_cast(Alignment) - 1) & ~(static_cast(Alignment) - 1)); } -template requires TIsIntegral::Value || TIsPointer::Value +template requires CIntegral || CPointer FORCEINLINE constexpr T AlignDown(T InValue, size_t Alignment) { checkf(IsValidAlignment(Alignment), TEXT("The alignment value must be an integer power of 2.")); return (T)((uint64)(InValue) & ~(static_cast(Alignment) - 1)); } -template requires TIsIntegral::Value || TIsPointer::Value +template requires CIntegral || CPointer FORCEINLINE constexpr T AlignArbitrary(T InValue, size_t Alignment) { checkf(IsValidAlignment(Alignment), TEXT("The alignment value must be an integer power of 2.")); return (T)((((uint64)(InValue) + static_cast(Alignment) - 1) / static_cast(Alignment)) * static_cast(Alignment)); } -template requires TIsIntegral::Value || TIsPointer::Value +template requires CIntegral || CPointer FORCEINLINE constexpr bool IsAligned(T InValue, size_t Alignment) { checkf(IsValidAlignment(Alignment), TEXT("The alignment value must be an integer power of 2.")); diff --git a/Redcraft.Utility/Source/Public/Memory/Memory.h b/Redcraft.Utility/Source/Public/Memory/Memory.h index cba328e..1ee8d15 100644 --- a/Redcraft.Utility/Source/Public/Memory/Memory.h +++ b/Redcraft.Utility/Source/Public/Memory/Memory.h @@ -56,21 +56,21 @@ FORCEINLINE void* Memcpy(void* Destination, const void* Source, size_t Count) template FORCEINLINE void Memset(T& Source, uint8 ValueToSet) { - static_assert(!TIsPointer::Value, "For pointers use the three parameters function"); + static_assert(!CPointer, "For pointers use the three parameters function"); Memset(&Source, ValueToSet, sizeof(T)); } template FORCEINLINE void Memzero(T& Source) { - static_assert(!TIsPointer::Value, "For pointers use the two parameters function"); + static_assert(!CPointer, "For pointers use the two parameters function"); Memzero(&Source, sizeof(T)); } template FORCEINLINE void Memcpy(T& Destination, const T& Source) { - static_assert(!TIsPointer::Value, "For pointers use the three parameters function"); + static_assert(!CPointer, "For pointers use the three parameters function"); Memcpy(&Destination, &Source, sizeof(T)); } diff --git a/Redcraft.Utility/Source/Public/Templates/Any.h b/Redcraft.Utility/Source/Public/Templates/Any.h index 97bf39c..b93f3d4 100644 --- a/Redcraft.Utility/Source/Public/Templates/Any.h +++ b/Redcraft.Utility/Source/Public/Templates/Any.h @@ -68,8 +68,7 @@ struct alignas(InlineAlignment) TAny } } - template requires TIsObject::Type>::Value - && (!TIsArray::Type>::Value) && TIsDestructible::Type>::Value + template requires TIsDestructible::Type>::Value && TIsConstructible::Type, Types...>::Value FORCEINLINE explicit TAny(TInPlaceType, Types&&... Args) { @@ -204,8 +203,7 @@ struct alignas(InlineAlignment) TAny return *this; } - template requires TIsObject::Type>::Value - && (!TIsArray::Type>::Value) && TIsDestructible::Type>::Value + template requires TIsDestructible::Type>::Value && TIsConstructible::Type, T&&>::Value FORCEINLINE typename TDecay::Type& Emplace(Types&&... Args) { diff --git a/Redcraft.Utility/Source/Public/Templates/Atomic.h b/Redcraft.Utility/Source/Public/Templates/Atomic.h index 55154fc..78b6b80 100644 --- a/Redcraft.Utility/Source/Public/Templates/Atomic.h +++ b/Redcraft.Utility/Source/Public/Templates/Atomic.h @@ -137,89 +137,89 @@ public: return Temp; } - FORCEINLINE ValueType FetchAdd(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (TIsIntegral::Value || TIsFloatingPoint::Value) { return Element.fetch_add(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchAdd(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (TIsIntegral::Value || TIsFloatingPoint::Value) && bIsAlwaysLockFree { return Element.fetch_add(InValue, static_cast(Order)); } + FORCEINLINE ValueType FetchAdd(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral || CFloatingPoint) { return Element.fetch_add(InValue, static_cast(Order)); } + FORCEINLINE ValueType FetchAdd(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral || CFloatingPoint) && bIsAlwaysLockFree { return Element.fetch_add(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchAdd(ptrdiff InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires TIsPointer::Value { return Element.fetch_add(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchAdd(ptrdiff InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires TIsPointer::Value && bIsAlwaysLockFree { return Element.fetch_add(InValue, static_cast(Order)); } + FORCEINLINE ValueType FetchAdd(ptrdiff InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires CPointer { return Element.fetch_add(InValue, static_cast(Order)); } + FORCEINLINE ValueType FetchAdd(ptrdiff InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires CPointer && bIsAlwaysLockFree { return Element.fetch_add(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchSub(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (TIsIntegral::Value || TIsFloatingPoint::Value) { return Element.fetch_sub(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchSub(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (TIsIntegral::Value || TIsFloatingPoint::Value) && bIsAlwaysLockFree { return Element.fetch_sub(InValue, static_cast(Order)); } + FORCEINLINE ValueType FetchSub(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral || CFloatingPoint) { return Element.fetch_sub(InValue, static_cast(Order)); } + FORCEINLINE ValueType FetchSub(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral || CFloatingPoint) && bIsAlwaysLockFree { return Element.fetch_sub(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchSub(ptrdiff InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires TIsPointer::Value { return Element.fetch_sub(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchSub(ptrdiff InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires TIsPointer::Value && bIsAlwaysLockFree { return Element.fetch_sub(InValue, static_cast(Order)); } + FORCEINLINE ValueType FetchSub(ptrdiff InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires CPointer { return Element.fetch_sub(InValue, static_cast(Order)); } + FORCEINLINE ValueType FetchSub(ptrdiff InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires CPointer && bIsAlwaysLockFree { return Element.fetch_sub(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchMul(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (TIsIntegral::Value || TIsFloatingPoint::Value) { return FetchFn([InValue](ValueType Old) -> ValueType { return Old * InValue; }); } - FORCEINLINE ValueType FetchMul(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (TIsIntegral::Value || TIsFloatingPoint::Value) && bIsAlwaysLockFree { return FetchFn([InValue](ValueType Old) -> ValueType { return Old * InValue; }); } + FORCEINLINE ValueType FetchMul(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral || CFloatingPoint) { return FetchFn([InValue](ValueType Old) -> ValueType { return Old * InValue; }); } + FORCEINLINE ValueType FetchMul(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral || CFloatingPoint) && bIsAlwaysLockFree { return FetchFn([InValue](ValueType Old) -> ValueType { return Old * InValue; }); } - FORCEINLINE ValueType FetchDiv(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (TIsIntegral::Value || TIsFloatingPoint::Value) { return FetchFn([InValue](ValueType Old) -> ValueType { return Old / InValue; }); } - FORCEINLINE ValueType FetchDiv(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (TIsIntegral::Value || TIsFloatingPoint::Value) && bIsAlwaysLockFree { return FetchFn([InValue](ValueType Old) -> ValueType { return Old / InValue; }); } + FORCEINLINE ValueType FetchDiv(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral || CFloatingPoint) { return FetchFn([InValue](ValueType Old) -> ValueType { return Old / InValue; }); } + FORCEINLINE ValueType FetchDiv(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral || CFloatingPoint) && bIsAlwaysLockFree { return FetchFn([InValue](ValueType Old) -> ValueType { return Old / InValue; }); } - FORCEINLINE ValueType FetchMod(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires TIsIntegral::Value { return FetchFn([InValue](ValueType Old) -> ValueType { return Old % InValue; }); } - FORCEINLINE ValueType FetchMod(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires TIsIntegral::Value && bIsAlwaysLockFree { return FetchFn([InValue](ValueType Old) -> ValueType { return Old % InValue; }); } + FORCEINLINE ValueType FetchMod(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires CIntegral { return FetchFn([InValue](ValueType Old) -> ValueType { return Old % InValue; }); } + FORCEINLINE ValueType FetchMod(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires CIntegral && bIsAlwaysLockFree { return FetchFn([InValue](ValueType Old) -> ValueType { return Old % InValue; }); } - FORCEINLINE ValueType FetchAnd(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires TIsIntegral::Value { return Element.fetch_and(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchAnd(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires TIsIntegral::Value && bIsAlwaysLockFree { return Element.fetch_and(InValue, static_cast(Order)); } + FORCEINLINE ValueType FetchAnd(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires CIntegral { return Element.fetch_and(InValue, static_cast(Order)); } + FORCEINLINE ValueType FetchAnd(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires CIntegral && bIsAlwaysLockFree { return Element.fetch_and(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchOr(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires TIsIntegral::Value { return Element.fetch_or(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchOr(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires TIsIntegral::Value && bIsAlwaysLockFree { return Element.fetch_or(InValue, static_cast(Order)); } + FORCEINLINE ValueType FetchOr(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires CIntegral { return Element.fetch_or(InValue, static_cast(Order)); } + FORCEINLINE ValueType FetchOr(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires CIntegral && bIsAlwaysLockFree { return Element.fetch_or(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchXor(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires TIsIntegral::Value { return Element.fetch_xor(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchXor(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires TIsIntegral::Value && bIsAlwaysLockFree { return Element.fetch_xor(InValue, static_cast(Order)); } + FORCEINLINE ValueType FetchXor(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires CIntegral { return Element.fetch_xor(InValue, static_cast(Order)); } + FORCEINLINE ValueType FetchXor(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires CIntegral && bIsAlwaysLockFree { return Element.fetch_xor(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchLsh(size_t InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires TIsIntegral::Value { return FetchFn([InValue](ValueType Old) -> ValueType { return Old << InValue; }); } - FORCEINLINE ValueType FetchLsh(size_t InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires TIsIntegral::Value && bIsAlwaysLockFree { return FetchFn([InValue](ValueType Old) -> ValueType { return Old << InValue; }); } + FORCEINLINE ValueType FetchLsh(size_t InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires CIntegral { return FetchFn([InValue](ValueType Old) -> ValueType { return Old << InValue; }); } + FORCEINLINE ValueType FetchLsh(size_t InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires CIntegral && bIsAlwaysLockFree { return FetchFn([InValue](ValueType Old) -> ValueType { return Old << InValue; }); } - FORCEINLINE ValueType FetchRsh(size_t InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires TIsIntegral::Value { return FetchFn([InValue](ValueType Old) -> ValueType { return Old >> InValue; }); } - FORCEINLINE ValueType FetchRsh(size_t InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires TIsIntegral::Value && bIsAlwaysLockFree { return FetchFn([InValue](ValueType Old) -> ValueType { return Old >> InValue; }); } + FORCEINLINE ValueType FetchRsh(size_t InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires CIntegral { return FetchFn([InValue](ValueType Old) -> ValueType { return Old >> InValue; }); } + FORCEINLINE ValueType FetchRsh(size_t InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires CIntegral && bIsAlwaysLockFree { return FetchFn([InValue](ValueType Old) -> ValueType { return Old >> InValue; }); } - FORCEINLINE ValueType operator++() requires (TIsIntegral::Value || TIsPointer::Value) { return ++Element; } - FORCEINLINE ValueType operator++() volatile requires (TIsIntegral::Value || TIsPointer::Value) && bIsAlwaysLockFree { return ++Element; } + FORCEINLINE ValueType operator++() requires (CIntegral || CPointer) { return ++Element; } + FORCEINLINE ValueType operator++() volatile requires (CIntegral || CPointer) && bIsAlwaysLockFree { return ++Element; } - FORCEINLINE ValueType operator++(int) requires (TIsIntegral::Value || TIsPointer::Value) { return Element++; } - FORCEINLINE ValueType operator++(int) volatile requires (TIsIntegral::Value || TIsPointer::Value) && bIsAlwaysLockFree { return Element++; } + FORCEINLINE ValueType operator++(int) requires (CIntegral || CPointer) { return Element++; } + FORCEINLINE ValueType operator++(int) volatile requires (CIntegral || CPointer) && bIsAlwaysLockFree { return Element++; } - FORCEINLINE ValueType operator--() requires (TIsIntegral::Value || TIsPointer::Value) { return --Element; } - FORCEINLINE ValueType operator--() volatile requires (TIsIntegral::Value || TIsPointer::Value) && bIsAlwaysLockFree { return --Element; } + FORCEINLINE ValueType operator--() requires (CIntegral || CPointer) { return --Element; } + FORCEINLINE ValueType operator--() volatile requires (CIntegral || CPointer) && bIsAlwaysLockFree { return --Element; } - FORCEINLINE ValueType operator--(int) requires (TIsIntegral::Value || TIsPointer::Value) { return Element--; } - FORCEINLINE ValueType operator--(int) volatile requires (TIsIntegral::Value || TIsPointer::Value) && bIsAlwaysLockFree { return Element--; } + FORCEINLINE ValueType operator--(int) requires (CIntegral || CPointer) { return Element--; } + FORCEINLINE ValueType operator--(int) volatile requires (CIntegral || CPointer) && bIsAlwaysLockFree { return Element--; } - FORCEINLINE ValueType operator+=(ValueType InValue) requires (TIsIntegral::Value || TIsFloatingPoint::Value) { return Element += InValue; } - FORCEINLINE ValueType operator+=(ValueType InValue) volatile requires (TIsIntegral::Value || TIsFloatingPoint::Value) && bIsAlwaysLockFree { return Element += InValue; } + FORCEINLINE ValueType operator+=(ValueType InValue) requires (CIntegral || CFloatingPoint) { return Element += InValue; } + FORCEINLINE ValueType operator+=(ValueType InValue) volatile requires (CIntegral || CFloatingPoint) && bIsAlwaysLockFree { return Element += InValue; } - FORCEINLINE ValueType operator+=(ptrdiff InValue) requires TIsPointer::Value { return Element += InValue; } - FORCEINLINE ValueType operator+=(ptrdiff InValue) volatile requires TIsPointer::Value && bIsAlwaysLockFree { return Element += InValue; } + FORCEINLINE ValueType operator+=(ptrdiff InValue) requires CPointer { return Element += InValue; } + FORCEINLINE ValueType operator+=(ptrdiff InValue) volatile requires CPointer && bIsAlwaysLockFree { return Element += InValue; } - FORCEINLINE ValueType operator-=(ValueType InValue) requires (TIsIntegral::Value || TIsFloatingPoint::Value) { return Element -= InValue; } - FORCEINLINE ValueType operator-=(ValueType InValue) volatile requires (TIsIntegral::Value || TIsFloatingPoint::Value) && bIsAlwaysLockFree { return Element -= InValue; } + FORCEINLINE ValueType operator-=(ValueType InValue) requires (CIntegral || CFloatingPoint) { return Element -= InValue; } + FORCEINLINE ValueType operator-=(ValueType InValue) volatile requires (CIntegral || CFloatingPoint) && bIsAlwaysLockFree { return Element -= InValue; } - FORCEINLINE ValueType operator-=(ptrdiff InValue) requires TIsPointer::Value { return Element -= InValue; } - FORCEINLINE ValueType operator-=(ptrdiff InValue) volatile requires TIsPointer::Value && bIsAlwaysLockFree { return Element -= InValue; } + FORCEINLINE ValueType operator-=(ptrdiff InValue) requires CPointer { return Element -= InValue; } + FORCEINLINE ValueType operator-=(ptrdiff InValue) volatile requires CPointer && bIsAlwaysLockFree { return Element -= InValue; } - FORCEINLINE ValueType operator*=(ValueType InValue) requires (TIsIntegral::Value || TIsFloatingPoint::Value) { return FetchMul(InValue) * InValue; } - FORCEINLINE ValueType operator*=(ValueType InValue) volatile requires (TIsIntegral::Value || TIsFloatingPoint::Value) && bIsAlwaysLockFree { return FetchMul(InValue) * InValue; } + FORCEINLINE ValueType operator*=(ValueType InValue) requires (CIntegral || CFloatingPoint) { return FetchMul(InValue) * InValue; } + FORCEINLINE ValueType operator*=(ValueType InValue) volatile requires (CIntegral || CFloatingPoint) && bIsAlwaysLockFree { return FetchMul(InValue) * InValue; } - FORCEINLINE ValueType operator/=(ValueType InValue) requires (TIsIntegral::Value || TIsFloatingPoint::Value) { return FetchDiv(InValue) / InValue; } - FORCEINLINE ValueType operator/=(ValueType InValue) volatile requires (TIsIntegral::Value || TIsFloatingPoint::Value) && bIsAlwaysLockFree { return FetchDiv(InValue) / InValue; } + FORCEINLINE ValueType operator/=(ValueType InValue) requires (CIntegral || CFloatingPoint) { return FetchDiv(InValue) / InValue; } + FORCEINLINE ValueType operator/=(ValueType InValue) volatile requires (CIntegral || CFloatingPoint) && bIsAlwaysLockFree { return FetchDiv(InValue) / InValue; } - FORCEINLINE ValueType operator%=(ValueType InValue) requires TIsIntegral::Value { return FetchMod(InValue) % InValue; } - FORCEINLINE ValueType operator%=(ValueType InValue) volatile requires TIsIntegral::Value && bIsAlwaysLockFree { return FetchMod(InValue) % InValue; } + FORCEINLINE ValueType operator%=(ValueType InValue) requires CIntegral { return FetchMod(InValue) % InValue; } + FORCEINLINE ValueType operator%=(ValueType InValue) volatile requires CIntegral && bIsAlwaysLockFree { return FetchMod(InValue) % InValue; } - FORCEINLINE ValueType operator&=(ValueType InValue) requires TIsIntegral::Value { return Element &= InValue; } - FORCEINLINE ValueType operator&=(ValueType InValue) volatile requires TIsIntegral::Value && bIsAlwaysLockFree { return Element &= InValue; } + FORCEINLINE ValueType operator&=(ValueType InValue) requires CIntegral { return Element &= InValue; } + FORCEINLINE ValueType operator&=(ValueType InValue) volatile requires CIntegral && bIsAlwaysLockFree { return Element &= InValue; } - FORCEINLINE ValueType operator|=(ValueType InValue) requires TIsIntegral::Value { return Element |= InValue; } - FORCEINLINE ValueType operator|=(ValueType InValue) volatile requires TIsIntegral::Value && bIsAlwaysLockFree { return Element |= InValue; } + FORCEINLINE ValueType operator|=(ValueType InValue) requires CIntegral { return Element |= InValue; } + FORCEINLINE ValueType operator|=(ValueType InValue) volatile requires CIntegral && bIsAlwaysLockFree { return Element |= InValue; } - FORCEINLINE ValueType operator^=(ValueType InValue) requires TIsIntegral::Value { return Element ^= InValue; } - FORCEINLINE ValueType operator^=(ValueType InValue) volatile requires TIsIntegral::Value && bIsAlwaysLockFree { return Element ^= InValue; } + FORCEINLINE ValueType operator^=(ValueType InValue) requires CIntegral { return Element ^= InValue; } + FORCEINLINE ValueType operator^=(ValueType InValue) volatile requires CIntegral && bIsAlwaysLockFree { return Element ^= InValue; } - FORCEINLINE ValueType operator<<=(size_t InValue) requires TIsIntegral::Value { return FetchLsh(InValue) << InValue; } - FORCEINLINE ValueType operator<<=(size_t InValue) volatile requires TIsIntegral::Value && bIsAlwaysLockFree { return FetchLsh(InValue) << InValue; } + FORCEINLINE ValueType operator<<=(size_t InValue) requires CIntegral { return FetchLsh(InValue) << InValue; } + FORCEINLINE ValueType operator<<=(size_t InValue) volatile requires CIntegral && bIsAlwaysLockFree { return FetchLsh(InValue) << InValue; } - FORCEINLINE ValueType operator>>=(size_t InValue) requires TIsIntegral::Value { return FetchRsh(InValue) >> InValue; } - FORCEINLINE ValueType operator>>=(size_t InValue) volatile requires TIsIntegral::Value && bIsAlwaysLockFree { return FetchRsh(InValue) >> InValue; } + FORCEINLINE ValueType operator>>=(size_t InValue) requires CIntegral { return FetchRsh(InValue) >> InValue; } + FORCEINLINE ValueType operator>>=(size_t InValue) volatile requires CIntegral && bIsAlwaysLockFree { return FetchRsh(InValue) >> InValue; } protected: diff --git a/Redcraft.Utility/Source/Public/Templates/Function.h b/Redcraft.Utility/Source/Public/Templates/Function.h index 43529a5..edf3b50 100644 --- a/Redcraft.Utility/Source/Public/Templates/Function.h +++ b/Redcraft.Utility/Source/Public/Templates/Function.h @@ -19,13 +19,13 @@ NAMESPACE_MODULE_BEGIN(Utility) inline constexpr size_t FUNCTION_DEFAULT_INLINE_SIZE = ANY_DEFAULT_INLINE_SIZE - sizeof(uintptr); inline constexpr size_t FUNCTION_DEFAULT_INLINE_ALIGNMENT = ANY_DEFAULT_INLINE_ALIGNMENT; -template requires TIsFunction::Value +template requires CFunction struct TFunctionRef; -template requires TIsFunction::Value && (Memory::IsValidAlignment(InlineAlignment)) +template requires CFunction && (Memory::IsValidAlignment(InlineAlignment)) struct TFunction; -template requires TIsFunction::Value && (Memory::IsValidAlignment(InlineAlignment)) +template requires CFunction && (Memory::IsValidAlignment(InlineAlignment)) struct TUniqueFunction; template struct TIsTFunctionRef : FFalse { }; @@ -42,7 +42,7 @@ NAMESPACE_PRIVATE_BEGIN template constexpr bool FunctionIsBound(const T& Func) { - if constexpr (TIsPointer::Value || TIsMemberPointer::Value || TIsTFunctionRef::Value || TIsTFunction::Value || TIsTUniqueFunction::Value) + if constexpr (CPointer || TIsMemberPointer::Value || TIsTFunctionRef::Value || TIsTFunction::Value || TIsTUniqueFunction::Value) { return !!Func; } @@ -213,7 +213,7 @@ protected: NAMESPACE_PRIVATE_END -template requires TIsFunction::Value +template requires CFunction struct TFunctionRef : public NAMESPACE_PRIVATE::TFunctionImpl< typename NAMESPACE_PRIVATE::TFunctionInfo::Fn, @@ -256,7 +256,7 @@ public: }; template - requires TIsFunction::Value && (Memory::IsValidAlignment(InlineAlignment)) + requires CFunction && (Memory::IsValidAlignment(InlineAlignment)) struct TFunction : public NAMESPACE_PRIVATE::TFunctionImpl< typename NAMESPACE_PRIVATE::TFunctionInfo::Fn, @@ -342,7 +342,7 @@ public: }; template - requires TIsFunction::Value && (Memory::IsValidAlignment(InlineAlignment)) + requires CFunction && (Memory::IsValidAlignment(InlineAlignment)) struct TUniqueFunction : public NAMESPACE_PRIVATE::TFunctionImpl< typename NAMESPACE_PRIVATE::TFunctionInfo::Fn, diff --git a/Redcraft.Utility/Source/Public/Templates/Invoke.h b/Redcraft.Utility/Source/Public/Templates/Invoke.h index 844a9b4..2e9dcdc 100644 --- a/Redcraft.Utility/Source/Public/Templates/Invoke.h +++ b/Redcraft.Utility/Source/Public/Templates/Invoke.h @@ -57,8 +57,8 @@ struct InvokeMemberObject template ::Type, - bool IsMemberFunction = TIsMemberFunctionPointer::Value, - bool IsMemberObject = TIsMemberObjectPointer::Value> + bool IsMemberFunction = CMemberFunctionPointer, + bool IsMemberObject = CMemberObjectPointer> struct InvokeMember; template @@ -91,8 +91,8 @@ constexpr auto Invoke(F&& Func, Types&&... Args) template requires TIsInvocableResult::Value constexpr R InvokeResult(F&& Func, Types&&... Args) { - if constexpr (TIsVoid::Value) 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 4b60b9b..93a84fb 100644 --- a/Redcraft.Utility/Source/Public/Templates/Optional.h +++ b/Redcraft.Utility/Source/Public/Templates/Optional.h @@ -12,7 +12,7 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -template requires TIsObject::Value && (!TIsArray::Value) && TIsDestructible::Value +template requires TIsDestructible::Value struct TOptional { private: @@ -283,19 +283,19 @@ constexpr bool operator==(const TOptional& LHS, FInvalid) return !LHS.IsValid(); } -template requires (TIsObject::Value && !TIsArray::Value && TIsDestructible::Value) +template requires TIsDestructible::Value constexpr TOptional::Type> MakeOptional(FInvalid) { return TOptional::Type>(Invalid); } -template requires (TIsObject::Value && !TIsArray::Value && TIsDestructible::Value) -constexpr TOptional::Type> MakeOptional(T&& InValue) +template requires TIsDestructible::Value && TIsConstructible::Value +constexpr TOptional MakeOptional(T&& InValue) { - return TOptional::Type>(Forward(InValue)); + return TOptional(Forward(InValue)); } -template requires (TIsObject::Value && !TIsArray::Value && TIsDestructible::Value) +template requires TIsDestructible::Value && TIsConstructible::Value constexpr TOptional MakeOptional(Types&&... 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 cba33e1..a0adb57 100644 --- a/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h +++ b/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h @@ -10,7 +10,7 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -template requires (TIsObject::Value || TIsFunction::Value) +template requires (TIsObject::Value || CFunction) struct TReferenceWrapper { public: @@ -61,11 +61,11 @@ private: ReferencedType* Pointer; - template requires (TIsObject::Value || TIsFunction::Value) friend struct TReferenceWrapper; + template requires (TIsObject::Value || CFunction) friend struct TReferenceWrapper; // Optimize TOptional with these hacking constexpr TReferenceWrapper(FInvalid) : Pointer(nullptr) { }; - template requires TIsObject::Value && (!TIsArray::Value) && TIsDestructible::Value friend struct TOptional; + template requires TIsDestructible::Value friend struct TOptional; }; @@ -221,7 +221,7 @@ public: private: TReferenceWrapper Reference; - template requires TIsObject::Value && (!TIsArray::Value) && TIsDestructible::Value friend struct TOptional; + template requires TIsDestructible::Value friend struct TOptional; }; diff --git a/Redcraft.Utility/Source/Public/Templates/Tuple.h b/Redcraft.Utility/Source/Public/Templates/Tuple.h index 97ceadb..cc3a889 100644 --- a/Redcraft.Utility/Source/Public/Templates/Tuple.h +++ b/Redcraft.Utility/Source/Public/Templates/Tuple.h @@ -448,7 +448,7 @@ template struct TTupleCatMake, TIndexSequence> { template - struct ForwardType { using Type = typename TConditional::Value, typename TRemoveReference::Type&&, U>::Type; }; + struct ForwardType { using Type = typename TConditional, typename TRemoveReference::Type&&, U>::Type; }; template static constexpr TTuple F(TTupleType&& InValue) diff --git a/Redcraft.Utility/Source/Public/Templates/TypeHash.h b/Redcraft.Utility/Source/Public/Templates/TypeHash.h index cb93e24..7b8f26a 100644 --- a/Redcraft.Utility/Source/Public/Templates/TypeHash.h +++ b/Redcraft.Utility/Source/Public/Templates/TypeHash.h @@ -47,7 +47,7 @@ constexpr size_t HashCombine(size_t A, size_t C, Ts... InOther) return HashCombine(B, InOther...); } -template requires TIsIntegral::Value +template requires CIntegral constexpr size_t GetTypeHash(T A) { static_assert(sizeof(T) <= 16, "GetTypeHash only works with T up to 128 bits."); @@ -60,7 +60,7 @@ constexpr size_t GetTypeHash(T A) return INDEX_NONE; } -template requires TIsFloatingPoint::Value +template requires CFloatingPoint constexpr size_t GetTypeHash(T A) { static_assert(sizeof(T) <= 16, "GetTypeHash only works with T up to 128 bits."); @@ -75,13 +75,13 @@ constexpr size_t GetTypeHash(T A) return INDEX_NONE; } -template requires TIsEnum::Value +template requires CEnum constexpr size_t GetTypeHash(T A) { return GetTypeHash(static_cast::Type>(A)); } -template requires TIsPointer::Value || TIsSame::Value +template requires CPointer || TIsSame::Value constexpr size_t GetTypeHash(T A) { return GetTypeHash(reinterpret_cast(A)); diff --git a/Redcraft.Utility/Source/Public/Templates/Variant.h b/Redcraft.Utility/Source/Public/Templates/Variant.h index af47adf..f449879 100644 --- a/Redcraft.Utility/Source/Public/Templates/Variant.h +++ b/Redcraft.Utility/Source/Public/Templates/Variant.h @@ -78,7 +78,7 @@ struct TVariantSelectedType NAMESPACE_PRIVATE_END -template requires (true && ... && (TIsObject::Value && !TIsArray::Value && TIsDestructible::Value)) && (sizeof...(Types) < 0xFF) +template requires (true && ... && TIsDestructible::Value) && (sizeof...(Types) < 0xFF) struct TVariant { static constexpr size_t AlternativeSize = sizeof...(Types); diff --git a/Redcraft.Utility/Source/Public/TypeTraits/BitwiseOperations.h b/Redcraft.Utility/Source/Public/TypeTraits/BitwiseOperations.h index 3583801..feb5ad6 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/BitwiseOperations.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/BitwiseOperations.h @@ -14,7 +14,7 @@ NAMESPACE_MODULE_BEGIN(Utility) // Assume that all operands of bitwise operations have the same size // This type traits is allowed to be specialised. -template struct TIsZeroConstructible : TBoolConstant::Value && (TIsEnum::Value || TIsArithmetic::Value || TIsPointer::Value)> { }; +template struct TIsZeroConstructible : TBoolConstant::Value && (CEnum || TIsArithmetic::Value || CPointer)> { }; // This type traits is allowed to be specialised. template struct TIsBitwiseConstructible; @@ -72,7 +72,7 @@ template struct TIsBitwiseRelocatable : TBoolConstant struct TIsBitwiseRelocatable : TBoolConstant::Value && TIsTriviallyDestructible::Value> { }; // This type traits is allowed to be specialised. -template struct TIsBitwiseComparable : TBoolConstant::Value || TIsArithmetic::Value || TIsPointer::Value> { }; +template struct TIsBitwiseComparable : TBoolConstant || TIsArithmetic::Value || CPointer> { }; NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) diff --git a/Redcraft.Utility/Source/Public/TypeTraits/PrimaryType.h b/Redcraft.Utility/Source/Public/TypeTraits/PrimaryType.h index 8abaf70..1b899ce 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/PrimaryType.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/PrimaryType.h @@ -9,20 +9,20 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -template struct TIsVoid : TBoolConstant> { }; -template struct TIsNullPointer : TBoolConstant> { }; -template struct TIsIntegral : TBoolConstant> { }; -template struct TIsFloatingPoint : TBoolConstant> { }; -template struct TIsArray : TBoolConstant> { }; -template struct TIsPointer : TBoolConstant> { }; -template struct TIsLValueReference : TBoolConstant> { }; -template struct TIsRValueReference : TBoolConstant> { }; -template struct TIsMemberObjectPointer : TBoolConstant> { }; -template struct TIsMemberFunctionPointer : TBoolConstant> { }; -template struct TIsEnum : TBoolConstant> { }; -template struct TIsUnion : TBoolConstant> { }; -template struct TIsClass : TBoolConstant> { }; -template struct TIsFunction : TBoolConstant> { }; +template concept CVoid = NAMESPACE_STD::is_void_v; +template concept CNullPointer = NAMESPACE_STD::is_null_pointer_v; +template concept CIntegral = NAMESPACE_STD::is_integral_v; +template concept CFloatingPoint = NAMESPACE_STD::is_floating_point_v; +template concept CArray = NAMESPACE_STD::is_array_v; +template concept CPointer = NAMESPACE_STD::is_pointer_v; +template concept CLValueReference = NAMESPACE_STD::is_lvalue_reference_v; +template concept CRValueReference = NAMESPACE_STD::is_rvalue_reference_v; +template concept CMemberObjectPointer = NAMESPACE_STD::is_member_object_pointer_v; +template concept CMemberFunctionPointer = NAMESPACE_STD::is_member_function_pointer_v; +template concept CEnum = NAMESPACE_STD::is_enum_v; +template concept CUnion = NAMESPACE_STD::is_union_v; +template concept CClass = NAMESPACE_STD::is_class_v; +template concept CFunction = NAMESPACE_STD::is_function_v; NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) diff --git a/Redcraft.Utility/Source/Public/TypeTraits/TypeProperties.h b/Redcraft.Utility/Source/Public/TypeTraits/TypeProperties.h index 37fe317..bf274cd 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/TypeProperties.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/TypeProperties.h @@ -27,7 +27,7 @@ template struct TIsBoundedArray : TBoolConstant struct TIsUnboundedArray : TBoolConstant> { }; template -struct TIsScopedEnum : TBoolConstant::Value && !TIsConvertible::Value> { }; +struct TIsScopedEnum : TBoolConstant && !TIsConvertible::Value> { }; NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft)