diff --git a/Redcraft.Utility/Source/Public/Memory/Alignment.h b/Redcraft.Utility/Source/Public/Memory/Alignment.h index 4c1577d..8e5f724 100644 --- a/Redcraft.Utility/Source/Public/Memory/Alignment.h +++ b/Redcraft.Utility/Source/Public/Memory/Alignment.h @@ -12,28 +12,28 @@ NAMESPACE_BEGIN(Memory) constexpr bool IsValidAlignment(size_t Alignment) { return !(Alignment & (Alignment - 1)); } -template requires CIntegral || CPointer +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 CIntegral || CPointer +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 CIntegral || CPointer +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 CIntegral || CPointer +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/MemoryOperator.h b/Redcraft.Utility/Source/Public/Memory/MemoryOperator.h index a90f5de..aff921e 100644 --- a/Redcraft.Utility/Source/Public/Memory/MemoryOperator.h +++ b/Redcraft.Utility/Source/Public/Memory/MemoryOperator.h @@ -11,8 +11,7 @@ NAMESPACE_MODULE_BEGIN(Utility) NAMESPACE_BEGIN(Memory) -template - requires CDefaultConstructible +template FORCEINLINE void DefaultConstruct(void* Address, size_t Count = 1) { if constexpr (!CTriviallyDefaultConstructible) @@ -27,7 +26,7 @@ FORCEINLINE void DefaultConstruct(void* Address, size_t Count = 1) } template - requires CConstructibleFrom + requires (CConstructibleFrom) FORCEINLINE void Construct(void* Destination, const SourceElementType* Source, size_t Count = 1) { if constexpr (CTriviallyConstructibleFrom && sizeof(DestinationElementType) == sizeof(SourceElementType)) @@ -46,8 +45,7 @@ FORCEINLINE void Construct(void* Destination, const SourceElementType* Source, s } } -template - requires CCopyConstructible +template FORCEINLINE void CopyConstruct(void* Destination, const ElementType* Source, size_t Count = 1) { if constexpr (CTriviallyCopyConstructible) @@ -66,8 +64,7 @@ FORCEINLINE void CopyConstruct(void* Destination, const ElementType* Source, siz } } -template - requires CMoveConstructible +template FORCEINLINE void MoveConstruct(void* Destination, ElementType* Source, size_t Count = 1) { if constexpr (CTriviallyMoveConstructible) @@ -86,8 +83,7 @@ FORCEINLINE void MoveConstruct(void* Destination, ElementType* Source, size_t Co } } -template - requires CCopyAssignable +template FORCEINLINE void CopyAssign(ElementType* Destination, const ElementType* Source, size_t Count = 1) { if constexpr (CTriviallyCopyAssignable) @@ -106,8 +102,7 @@ FORCEINLINE void CopyAssign(ElementType* Destination, const ElementType* Source, } } -template - requires CMoveAssignable +template FORCEINLINE void MoveAssign(ElementType* Destination, ElementType* Source, size_t Count = 1) { if constexpr (CTriviallyMoveAssignable) @@ -126,8 +121,7 @@ FORCEINLINE void MoveAssign(ElementType* Destination, ElementType* Source, size_ } } -template - requires CDestructible +template FORCEINLINE void Destruct(ElementType* Element, size_t Count = 1) { if constexpr (!CTriviallyDestructible) diff --git a/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h b/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h index 07da723..ef7d3a1 100644 --- a/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h +++ b/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h @@ -56,13 +56,13 @@ concept CThreeWayComparable = CWeaklyEqualityComparable && CPartiallyOrder { C <=> C } -> CThreeWayComparesAs; }; -template requires CThreeWayComparable +template requires (CThreeWayComparable) using TCompareThreeWayResult = decltype(DeclVal&>() <=> DeclVal&>()); template concept CSynthThreeWayComparable = CThreeWayComparable || CTotallyOrdered; -template requires CSynthThreeWayComparable +template requires (CSynthThreeWayComparable) constexpr decltype(auto) SynthThreeWayCompare(T&& LHS, U&& RHS) { if constexpr (CThreeWayComparable) @@ -75,7 +75,7 @@ constexpr decltype(auto) SynthThreeWayCompare(T&& LHS, U&& RHS) } } -template requires CSynthThreeWayComparable +template requires (CSynthThreeWayComparable) using TSynthThreeWayResult = 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 adf01c0..91b644f 100644 --- a/Redcraft.Utility/Source/Public/Templates/Any.h +++ b/Redcraft.Utility/Source/Public/Templates/Any.h @@ -13,11 +13,11 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -// TAny's CustomStorage concept, see FAnyDefaultStorage. +// TAny's CustomStorage concept, see FAnyDefaultStorage template concept CAnyCustomStorage = -// CSameAs && -// CSameAs && + CSameAs && + CSameAs && requires(const T& A) { { A.InlineAllocation() } -> CSameAs; @@ -36,12 +36,12 @@ concept CAnyCustomStorage = A.MoveCustom(MoveTemp(C)); }; -// TAny's default storage structure. +// TAny's default storage structure struct alignas(16) FAnyDefaultStorage { - // The built-in copy/move operators are disabled and CopyCustom/MoveCustom is used instead of them. + // The built-in copy/move operators are disabled and CopyCustom/MoveCustom is used instead of them - // You can add custom variables like this. + // You can add custom variables like this //Type Variable; //~ Begin CAnyCustomStorage Interface @@ -53,8 +53,8 @@ struct alignas(16) FAnyDefaultStorage constexpr void* HeapAllocation() const { return HeapAllocationImpl; } constexpr uintptr& TypeInfo() { return TypeInfoImpl; } constexpr uintptr TypeInfo() const { return TypeInfoImpl; } - constexpr void CopyCustom(const FAnyDefaultStorage& InValue) { /* Variable = InValue.Variable; */ } // You just need to copy the custom variables. - constexpr void MoveCustom( FAnyDefaultStorage&& InValue) { /* Variable = MoveTemp(InValue.Variable); */ } // You just need to move the custom variables. + constexpr void CopyCustom(const FAnyDefaultStorage& InValue) { /* Variable = InValue.Variable; */ } // You just need to copy the custom variables + constexpr void MoveCustom( FAnyDefaultStorage&& InValue) { /* Variable = MoveTemp(InValue.Variable); */ } // You just need to move the custom variables //~ End CAnyCustomStorage Interface union @@ -69,8 +69,8 @@ struct alignas(16) FAnyDefaultStorage static_assert(CAnyCustomStorage); -// You can add custom storage area through CustomStorage, such as TFunction. -// It is not recommended to use this, FAny is recommended. +// You can add custom storage area through CustomStorage, such as TFunction +// It is not recommended to use this, FAny is recommended template class TAny { @@ -131,15 +131,15 @@ public: } } - template requires CDestructible> - && CConstructibleFrom, Ts&&...> + template requires (CDestructible> + && CConstructibleFrom, Ts&&...>) FORCEINLINE explicit TAny(TInPlaceType, Ts&&... Args) { using SelectedType = TDecay; EmplaceImpl(Forward(Args)...); } - template requires (!CSameAs, TAny>) && (!CTInPlaceType>) + template requires (!CSameAs, TAny> && !CTInPlaceType>) && CDestructible> && CConstructibleFrom, T&&> FORCEINLINE TAny(T&& InValue) : TAny(InPlaceType>, Forward(InValue)) { } @@ -251,7 +251,7 @@ public: return *this; } - template requires (!CSameAs, TAny>) && (!CTInPlaceType>) + template requires (!CSameAs, TAny> && !CTInPlaceType>) && CDestructible> && CConstructibleFrom, T&&> FORCEINLINE TAny& operator=(T&& InValue) { @@ -270,8 +270,8 @@ public: return *this; } - template requires CDestructible> - && CConstructibleFrom, Ts&&...> + template requires (CDestructible> + && CConstructibleFrom, Ts&&...>) FORCEINLINE TDecay& Emplace(Ts&&... Args) { ResetImpl(); @@ -288,22 +288,22 @@ public: template constexpr bool HoldsAlternative() const { return IsValid() ? GetTypeInfo() == typeid(T) : false; } - template requires CDestructible> + 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> + 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> + 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> + 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>&& CDestructible> + template requires (CSameAs> && CDestructible>) constexpr T& Get( T& DefaultValue) & { return HoldsAlternative() ? GetValue() : DefaultValue; } - template requires CSameAs>&& CDestructible> + template requires (CSameAs> && CDestructible>) constexpr const T& Get(const T& DefaultValue) const& { return HoldsAlternative() ? GetValue() : DefaultValue; } constexpr CustomStorage& GetCustomStorage() requires (!CSameAs) { return Storage; } diff --git a/Redcraft.Utility/Source/Public/Templates/Atomic.h b/Redcraft.Utility/Source/Public/Templates/Atomic.h index 7145813..aaf41da 100644 --- a/Redcraft.Utility/Source/Public/Templates/Atomic.h +++ b/Redcraft.Utility/Source/Public/Templates/Atomic.h @@ -51,9 +51,9 @@ NAMESPACE_PRIVATE_END #endif -template requires CTriviallyCopyable +template requires (CTriviallyCopyable && CCopyConstructible && CMoveConstructible - && CCopyAssignable && CMoveAssignable + && CCopyAssignable && CMoveAssignable) struct TAtomic : public FSingleton { protected: @@ -74,20 +74,20 @@ public: FORCEINLINE explicit TAtomic(ValueType& Desired) requires (bIsRef) : Element(Desired) { check(Memory::IsAligned(&Desired, RequiredAlignment)); }; FORCEINLINE TAtomic(TAtomic& InValue) requires (bIsRef) : Element(InValue) { }; - FORCEINLINE ValueType operator=(ValueType Desired) { return Element = Desired; } - FORCEINLINE ValueType operator=(ValueType Desired) volatile requires bIsAlwaysLockFree { return Element = Desired; } + FORCEINLINE ValueType operator=(ValueType Desired) { return Element = Desired; } + FORCEINLINE ValueType operator=(ValueType Desired) volatile requires (bIsAlwaysLockFree) { return Element = Desired; } - FORCEINLINE void Store(ValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) { MEMORY_ORDER_CHECK(Order, 0x01 | 0x08 | 0x20); Element.store(Desired, static_cast(Order)); } - FORCEINLINE void Store(ValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires bIsAlwaysLockFree { MEMORY_ORDER_CHECK(Order, 0x01 | 0x08 | 0x20); Element.store(Desired, static_cast(Order)); } + FORCEINLINE void Store(ValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) { MEMORY_ORDER_CHECK(Order, 0x01 | 0x08 | 0x20); Element.store(Desired, static_cast(Order)); } + FORCEINLINE void Store(ValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (bIsAlwaysLockFree) { MEMORY_ORDER_CHECK(Order, 0x01 | 0x08 | 0x20); Element.store(Desired, static_cast(Order)); } - FORCEINLINE ValueType Load(EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) const { MEMORY_ORDER_CHECK(Order, 0x01 | 0x02 | 0x04 | 0x20); return Element.load(static_cast(Order)); } - FORCEINLINE ValueType Load(EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) const volatile requires bIsAlwaysLockFree { MEMORY_ORDER_CHECK(Order, 0x01 | 0x02 | 0x04 | 0x20); return Element.load(static_cast(Order)); } + FORCEINLINE ValueType Load(EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) const { MEMORY_ORDER_CHECK(Order, 0x01 | 0x02 | 0x04 | 0x20); return Element.load(static_cast(Order)); } + FORCEINLINE ValueType Load(EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) const volatile requires (bIsAlwaysLockFree) { MEMORY_ORDER_CHECK(Order, 0x01 | 0x02 | 0x04 | 0x20); return Element.load(static_cast(Order)); } - FORCEINLINE operator ValueType() const { return static_cast(Element); } - FORCEINLINE operator ValueType() const volatile requires bIsAlwaysLockFree { return static_cast(Element); } + FORCEINLINE operator ValueType() const { return static_cast(Element); } + FORCEINLINE operator ValueType() const volatile requires (bIsAlwaysLockFree) { return static_cast(Element); } - FORCEINLINE ValueType Exchange(ValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) { return Element.exchange(Desired, static_cast(Order)); } - FORCEINLINE ValueType Exchange(ValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires bIsAlwaysLockFree { return Element.exchange(Desired, static_cast(Order)); } + FORCEINLINE ValueType Exchange(ValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) { return Element.exchange(Desired, static_cast(Order)); } + FORCEINLINE ValueType Exchange(ValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (bIsAlwaysLockFree) { return Element.exchange(Desired, static_cast(Order)); } FORCEINLINE bool CompareExchange(ValueType& Expected, ValueType Desired, EMemoryOrder Success, EMemoryOrder Failure, bool bIsWeak = false) { @@ -96,7 +96,7 @@ public: else return Element.compare_exchange_strong(Expected, Desired, static_cast(Success), static_cast(Failure)); } - FORCEINLINE bool CompareExchange(ValueType& Expected, ValueType Desired, EMemoryOrder Success, EMemoryOrder Failure, bool bIsWeak = false) volatile requires bIsAlwaysLockFree + FORCEINLINE bool CompareExchange(ValueType& Expected, ValueType Desired, EMemoryOrder Success, EMemoryOrder Failure, bool bIsWeak = false) volatile requires (bIsAlwaysLockFree) { MEMORY_ORDER_CHECK(Failure, 0x01 | 0x02 | 0x04 | 0x20); if (bIsWeak) return Element.compare_exchange_weak(Expected, Desired, static_cast(Success), static_cast(Failure)); @@ -109,7 +109,7 @@ public: else return Element.compare_exchange_strong(Expected, Desired, static_cast(Order)); } - FORCEINLINE bool CompareExchange(ValueType& Expected, ValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent, bool bIsWeak = false) volatile requires bIsAlwaysLockFree + FORCEINLINE bool CompareExchange(ValueType& Expected, ValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent, bool bIsWeak = false) volatile requires (bIsAlwaysLockFree) { if (bIsWeak) return Element.compare_exchange_weak(Expected, Desired, static_cast(Order)); else return Element.compare_exchange_strong(Expected, Desired, static_cast(Order)); @@ -121,7 +121,7 @@ public: FORCEINLINE void Notify(bool bIsAll = false) { if (bIsAll) Element.notify_all(); else Element.notify_one(); } FORCEINLINE void Notify(bool bIsAll = false) volatile { if (bIsAll) Element.notify_all(); else Element.notify_one(); } - template requires CInvocableResult + template requires (CInvocableResult) FORCEINLINE ValueType FetchFn(F&& Func, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) { ValueType Temp(Load(EMemoryOrder::Relaxed)); @@ -129,7 +129,7 @@ public: return Temp; } - template requires CInvocableResult && bIsAlwaysLockFree + template requires (CInvocableResult && bIsAlwaysLockFree) FORCEINLINE ValueType FetchFn(F&& Func, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile { ValueType Temp(Load(EMemoryOrder::Relaxed)); @@ -140,14 +140,14 @@ public: 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 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 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 (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 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 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 (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; }); } @@ -155,71 +155,71 @@ public: 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 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 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 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 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 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 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 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 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 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 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 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 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 (CIntegral || CPointer) { return ++Element; } - FORCEINLINE ValueType operator++() volatile requires (CIntegral || CPointer) && 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 (CIntegral || CPointer) { return Element++; } - FORCEINLINE ValueType operator++(int) volatile requires (CIntegral || CPointer) && 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 (CIntegral || CPointer) { return --Element; } - FORCEINLINE ValueType operator--() volatile requires (CIntegral || CPointer) && 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 (CIntegral || CPointer) { return Element--; } - FORCEINLINE ValueType operator--(int) volatile requires (CIntegral || CPointer) && 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 (CIntegral || CFloatingPoint) { return Element += InValue; } - FORCEINLINE ValueType operator+=(ValueType InValue) volatile requires (CIntegral || CFloatingPoint) && 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 CPointer { return Element += InValue; } - FORCEINLINE ValueType operator+=(ptrdiff InValue) volatile requires CPointer && 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 (CIntegral || CFloatingPoint) { return Element -= InValue; } - FORCEINLINE ValueType operator-=(ValueType InValue) volatile requires (CIntegral || CFloatingPoint) && 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 CPointer { return Element -= InValue; } - FORCEINLINE ValueType operator-=(ptrdiff InValue) volatile requires CPointer && 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 (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 ((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 (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 ((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 CIntegral { return FetchMod(InValue) % InValue; } - FORCEINLINE ValueType operator%=(ValueType InValue) volatile requires CIntegral && 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 CIntegral { return Element &= InValue; } - FORCEINLINE ValueType operator&=(ValueType InValue) volatile requires CIntegral && 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 CIntegral { return Element |= InValue; } - FORCEINLINE ValueType operator|=(ValueType InValue) volatile requires CIntegral && 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 CIntegral { return Element ^= InValue; } - FORCEINLINE ValueType operator^=(ValueType InValue) volatile requires CIntegral && 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 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 (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 CIntegral { return FetchRsh(InValue) >> InValue; } - FORCEINLINE ValueType operator>>=(size_t InValue) volatile requires CIntegral && 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/Container.h b/Redcraft.Utility/Source/Public/Templates/Container.h index f58743a..650e75f 100644 --- a/Redcraft.Utility/Source/Public/Templates/Container.h +++ b/Redcraft.Utility/Source/Public/Templates/Container.h @@ -6,7 +6,7 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -template requires requires(T&& Container) { Container.GetData(); } +template requires (requires(T&& Container) { Container.GetData(); }) constexpr decltype(auto) GetData(T&& Container) { return Container.GetData(); @@ -17,13 +17,13 @@ template constexpr T* GetData( T(&& Container) template constexpr const T* GetData(const T(& Container)[N]) { return Container; } template constexpr const T* GetData(const T(&& Container)[N]) { return Container; } -template requires requires(T&& Container) { Container.data(); } +template requires (requires(T&& Container) { Container.data(); }) constexpr decltype(auto) GetData(T&& Container) { return Container.data(); } -template requires requires(T&& Container) { Container.Num(); } +template requires (requires(T&& Container) { Container.Num(); }) constexpr decltype(auto) GetNum(T&& Container) { return Container.Num(); @@ -34,7 +34,7 @@ template constexpr size_t GetNum( T(&& Container)[N] template constexpr size_t GetNum(const T(& Container)[N]) { return N; } template constexpr size_t GetNum(const T(&& Container)[N]) { return N; } -template requires requires(T&& Container) { Container.size(); } +template requires (requires(T&& Container) { Container.size(); }) constexpr decltype(auto) GetNum(T&& Container) { return Container.size(); diff --git a/Redcraft.Utility/Source/Public/Templates/Function.h b/Redcraft.Utility/Source/Public/Templates/Function.h index b30cb56..cd8391c 100644 --- a/Redcraft.Utility/Source/Public/Templates/Function.h +++ b/Redcraft.Utility/Source/Public/Templates/Function.h @@ -109,10 +109,10 @@ public: FORCEINLINE const type_info& TargetType() const requires (!bIsRef) { return IsValid() ? Storage.GetTypeInfo() : typeid(void); }; - 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(); } + 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) { @@ -207,7 +207,7 @@ private: else return GetCallableImpl()(&Storage, Forward(Args)...); } -protected: // These functions should not be used by user-defined class. +protected: // These functions should not be used by user-defined class template FORCEINLINE void EmplaceImpl(ArgTypes&&... Args) @@ -281,8 +281,8 @@ public: TFunctionRef& operator=(const TFunctionRef& InValue) = delete; TFunctionRef& operator=(TFunctionRef&& InValue) = delete; - template requires (!CTFunctionRef>) && (!CTInPlaceType>) - && NAMESPACE_PRIVATE::TIsInvocableSignature>::Value + template requires (!CTFunctionRef> && !CTInPlaceType> + && NAMESPACE_PRIVATE::TIsInvocableSignature>::Value) FORCEINLINE TFunctionRef(T&& InValue) { using DecayedType = TDecay; @@ -329,10 +329,10 @@ public: return *this; } - template requires (!CTInPlaceType>) - && (!CTFunctionRef>) && (!CTFunction>) && (!CTUniqueFunction>) + template requires (!CTInPlaceType> + && !CTFunctionRef> && !CTFunction> && !CTUniqueFunction> && CConstructibleFrom, T&&> && CCopyConstructible> - && NAMESPACE_PRIVATE::TIsInvocableSignature>::Value + && NAMESPACE_PRIVATE::TIsInvocableSignature>::Value) FORCEINLINE TFunction(T&& InValue) { using DecayedType = TDecay; @@ -340,8 +340,8 @@ public: else Impl::template EmplaceImpl(Forward(InValue)); } - template requires NAMESPACE_PRIVATE::TIsInvocableSignature>::Value - && CConstructibleFrom, ArgTypes...> && CCopyConstructible> + template requires (NAMESPACE_PRIVATE::TIsInvocableSignature>::Value + && CConstructibleFrom, ArgTypes...> && CCopyConstructible>) FORCEINLINE TFunction(TInPlaceType, ArgTypes&&... Args) { using DecayedType = TDecay; @@ -350,9 +350,9 @@ public: constexpr TFunction& operator=(nullptr_t) { Impl::ResetImpl(); return *this; } - template requires NAMESPACE_PRIVATE::TIsInvocableSignature>::Value - && (!CTFunctionRef>) && (!CTFunction>) && (!CTUniqueFunction>) - && CConstructibleFrom, T&&> && CCopyConstructible> + template requires (NAMESPACE_PRIVATE::TIsInvocableSignature>::Value + && !CTFunctionRef> && !CTFunction> && !CTUniqueFunction> + && CConstructibleFrom, T&&> && CCopyConstructible>) FORCEINLINE TFunction& operator=(T&& InValue) { using DecayedType = TDecay; @@ -363,8 +363,8 @@ public: return *this; } - template requires NAMESPACE_PRIVATE::TIsInvocableSignature>::Value - && CConstructibleFrom, ArgTypes...>&& CCopyConstructible> + template requires (NAMESPACE_PRIVATE::TIsInvocableSignature>::Value + && CConstructibleFrom, ArgTypes...> && CCopyConstructible>) FORCEINLINE TDecay& Emplace(ArgTypes&&... Args) { using DecayedType = TDecay; @@ -427,10 +427,10 @@ public: return *this; } - template requires (!CTInPlaceType>) - && (!CTFunctionRef>) && (!CTFunction>) && (!CTUniqueFunction>) + template requires (!CTInPlaceType> + && !CTFunctionRef> && !CTFunction> && !CTUniqueFunction> && CConstructibleFrom, T&&> && CMoveConstructible> - && NAMESPACE_PRIVATE::TIsInvocableSignature>::Value + && NAMESPACE_PRIVATE::TIsInvocableSignature>::Value) FORCEINLINE TUniqueFunction(T&& InValue) { using DecayedType = TDecay; @@ -438,8 +438,8 @@ public: else Impl::template EmplaceImpl(Forward(InValue)); } - template requires NAMESPACE_PRIVATE::TIsInvocableSignature>::Value - && CConstructibleFrom, ArgTypes...> && CMoveConstructible> + template requires (NAMESPACE_PRIVATE::TIsInvocableSignature>::Value + && CConstructibleFrom, ArgTypes...> && CMoveConstructible>) FORCEINLINE TUniqueFunction(TInPlaceType, ArgTypes&&... Args) { using DecayedType = TDecay; @@ -448,9 +448,9 @@ public: constexpr TUniqueFunction& operator=(nullptr_t) { Impl::ResetImpl(); return *this; } - template requires NAMESPACE_PRIVATE::TIsInvocableSignature>::Value - && (!CTFunctionRef>) && (!CTFunction>) && (!CTUniqueFunction>) - && CConstructibleFrom, T&&>&& CMoveConstructible> + template requires (NAMESPACE_PRIVATE::TIsInvocableSignature>::Value + && !CTFunctionRef> && !CTFunction> && !CTUniqueFunction> + && CConstructibleFrom, T&&> && CMoveConstructible>) FORCEINLINE TUniqueFunction& operator=(T&& InValue) { using DecayedType = TDecay; @@ -461,8 +461,8 @@ public: return *this; } - template requires NAMESPACE_PRIVATE::TIsInvocableSignature>::Value - && CConstructibleFrom, ArgTypes...>&& CMoveConstructible> + template requires (NAMESPACE_PRIVATE::TIsInvocableSignature>::Value + && CConstructibleFrom, ArgTypes...> && CMoveConstructible>) FORCEINLINE TDecay& Emplace(ArgTypes&&... Args) { using DecayedType = TDecay; @@ -508,28 +508,28 @@ struct TNotFunction template constexpr TNotFunction(InF&& InFunc) : Storage(Forward(InFunc)) { } - template requires CInvocable + template requires (CInvocable) constexpr auto operator()(Ts&&... Args) & -> decltype(!Invoke(Storage, Forward(Args)...)) { return !Invoke(Storage, Forward(Args)...); } - template requires CInvocable + template requires (CInvocable) constexpr auto operator()(Ts&&... Args) && -> decltype(!Invoke(MoveTemp(Storage), Forward(Args)...)) { return !Invoke(MoveTemp(Storage), Forward(Args)...); } - template requires CInvocable + template requires (CInvocable) constexpr auto operator()(Ts&&... Args) const& -> decltype(!Invoke(Storage, Forward(Args)...)) { return !Invoke(Storage, Forward(Args)...); } - template requires CInvocable + template requires (CInvocable) constexpr auto operator()(Ts&&... Args) const&& -> decltype(!Invoke(MoveTemp(Storage), Forward(Args)...)) { @@ -539,7 +539,7 @@ struct TNotFunction NAMESPACE_PRIVATE_END -template +template requires (CConstructibleFrom) constexpr NAMESPACE_PRIVATE::TNotFunction> NotFn(F&& Func) { return NAMESPACE_PRIVATE::TNotFunction>(Forward(Func)); diff --git a/Redcraft.Utility/Source/Public/Templates/Invoke.h b/Redcraft.Utility/Source/Public/Templates/Invoke.h index 9f99a61..3653de3 100644 --- a/Redcraft.Utility/Source/Public/Templates/Invoke.h +++ b/Redcraft.Utility/Source/Public/Templates/Invoke.h @@ -81,14 +81,14 @@ struct InvokeImpl : InvokeMember { }; NAMESPACE_PRIVATE_END -template requires CInvocable +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)...); } -template requires CInvocableResult +template requires (CInvocableResult) constexpr R InvokeResult(F&& Func, Ts&&... Args) { if constexpr (CVoid) Invoke(Forward(Func), Forward(Args)...); diff --git a/Redcraft.Utility/Source/Public/Templates/Optional.h b/Redcraft.Utility/Source/Public/Templates/Optional.h index e3fdb44..7deb2f6 100644 --- a/Redcraft.Utility/Source/Public/Templates/Optional.h +++ b/Redcraft.Utility/Source/Public/Templates/Optional.h @@ -11,7 +11,7 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -template requires CDestructible +template requires (CDestructible) class TOptional { private: @@ -40,39 +40,39 @@ public: constexpr TOptional(FInvalid) : TOptional() { } - template requires CConstructibleFrom + template requires (CConstructibleFrom) constexpr explicit TOptional(FInPlace, Ts&&... Args) : bIsValid(true) { new(&Value) OptionalType(Forward(Args)...); } - template requires CConstructibleFrom + template requires (CConstructibleFrom) && (!CSameAs, FInPlace>) && (!CSameAs, TOptional>) constexpr explicit (!CConvertibleTo) TOptional(T&& InValue) : TOptional(InPlace, Forward(InValue)) { } - constexpr TOptional(const TOptional& InValue) requires CCopyConstructible + constexpr TOptional(const TOptional& InValue) requires (CCopyConstructible) : bIsValid(InValue.IsValid()) { if (InValue.IsValid()) new(&Value) OptionalType(InValue.GetValue()); } - constexpr TOptional(TOptional&& InValue) requires CMoveConstructible + constexpr TOptional(TOptional&& InValue) requires (CMoveConstructible) : bIsValid(InValue.IsValid()) { if (InValue.IsValid()) new(&Value) OptionalType(MoveTemp(InValue.GetValue())); } - template requires CConstructibleFrom && TAllowUnwrapping::Value + template requires (CConstructibleFrom && TAllowUnwrapping::Value) constexpr explicit (!CConvertibleTo) TOptional(const TOptional& InValue) : bIsValid(InValue.IsValid()) { if (InValue.IsValid()) new(&Value) OptionalType(InValue.GetValue()); } - template requires CConstructibleFrom && TAllowUnwrapping::Value + template requires (CConstructibleFrom && TAllowUnwrapping::Value) constexpr explicit (!CConvertibleTo) TOptional(TOptional&& InValue) : bIsValid(InValue.IsValid()) { @@ -84,7 +84,7 @@ public: if constexpr (!CTriviallyDestructible) Reset(); } - constexpr TOptional& operator=(const TOptional& InValue) requires CCopyConstructible && CCopyAssignable + constexpr TOptional& operator=(const TOptional& InValue) requires (CCopyConstructible && CCopyAssignable) { if (&InValue == this) return *this; @@ -104,7 +104,7 @@ public: return *this; } - constexpr TOptional& operator=(TOptional&& InValue) requires CMoveConstructible && CMoveAssignable + constexpr TOptional& operator=(TOptional&& InValue) requires (CMoveConstructible && CMoveAssignable) { if (&InValue == this) return *this; @@ -124,8 +124,8 @@ public: return *this; } - template requires CConstructibleFrom - && CAssignableFrom && TAllowUnwrapping::Value + template requires (CConstructibleFrom + && CAssignableFrom && TAllowUnwrapping::Value) constexpr TOptional& operator=(const TOptional& InValue) { if (!InValue.IsValid()) @@ -144,8 +144,8 @@ public: return *this; } - template requires CConstructibleFrom - && CAssignableFrom && TAllowUnwrapping::Value + template requires (CConstructibleFrom + && CAssignableFrom && TAllowUnwrapping::Value) constexpr TOptional& operator=(TOptional&& InValue) { if (!InValue.IsValid()) @@ -164,7 +164,7 @@ public: return *this; } - template requires CConstructibleFrom && CAssignableFrom + template requires (CConstructibleFrom && CAssignableFrom) constexpr TOptional& operator=(T&& InValue) { if (IsValid()) GetValue() = Forward(InValue); @@ -177,7 +177,7 @@ public: return *this; } - template requires CConstructibleFrom + template requires (CConstructibleFrom) constexpr OptionalType& Emplace(ArgTypes&&... Args) { Reset(); @@ -218,13 +218,13 @@ public: } } - constexpr size_t GetTypeHash() const requires CHashable + constexpr size_t GetTypeHash() const requires (CHashable) { if (!IsValid()) return 2824517378; return NAMESPACE_REDCRAFT::GetTypeHash(GetValue()); } - template requires CMoveConstructible && CSwappable + template requires (CMoveConstructible && CSwappable) constexpr void Swap(TOptional& InValue) { if (!IsValid() && !InValue.IsValid()) return; @@ -256,7 +256,7 @@ private: template TOptional(T) -> TOptional; -template requires CWeaklyEqualityComparable +template requires (CWeaklyEqualityComparable) constexpr bool operator==(const TOptional& LHS, const TOptional& RHS) { if (LHS.IsValid() != RHS.IsValid()) return false; @@ -264,7 +264,7 @@ constexpr bool operator==(const TOptional& LHS, const TOptional& RHS) return *LHS == *RHS; } -template requires CSynthThreeWayComparable +template requires (CSynthThreeWayComparable) constexpr partial_ordering operator<=>(const TOptional& LHS, const TOptional& RHS) { if (LHS.IsValid() != RHS.IsValid()) return partial_ordering::unordered; @@ -272,7 +272,7 @@ constexpr partial_ordering operator<=>(const TOptional& LHS, const TOptional< return SynthThreeWayCompare(*LHS, *RHS); } -template requires CWeaklyEqualityComparable +template requires (CWeaklyEqualityComparable) constexpr bool operator==(const TOptional& LHS, const U& RHS) { return LHS.IsValid() ? *LHS == RHS : false; @@ -284,19 +284,19 @@ constexpr bool operator==(const TOptional& LHS, FInvalid) return !LHS.IsValid(); } -template requires CDestructible +template requires (CDestructible) constexpr TOptional> MakeOptional(FInvalid) { return TOptional>(Invalid); } -template requires CDestructible && CConstructibleFrom +template requires (CDestructible && CConstructibleFrom) constexpr TOptional MakeOptional(T&& InValue) { return TOptional(Forward(InValue)); } -template requires CDestructible && CConstructibleFrom +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 0270404..6087b57 100644 --- a/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h +++ b/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h @@ -17,7 +17,7 @@ public: using Type = ReferencedType; - template requires CConvertibleTo + template requires (CConvertibleTo) constexpr TReferenceWrapper(T&& Object) { ReferencedType& Reference = Forward(Object); @@ -26,14 +26,14 @@ public: TReferenceWrapper(const TReferenceWrapper&) = default; - template requires CConvertibleTo + template requires (CConvertibleTo) constexpr TReferenceWrapper(const TReferenceWrapper& InValue) : Pointer(InValue.Pointer) { } TReferenceWrapper& operator=(const TReferenceWrapper&) = default; - template requires CConvertibleTo + template requires (CConvertibleTo) constexpr TReferenceWrapper& operator=(const TReferenceWrapper& InValue) { Pointer = InValue.Pointer; @@ -49,7 +49,7 @@ public: return Invoke(Get(), Forward(Args)...); } - constexpr size_t GetTypeHash() const requires CHashable + constexpr size_t GetTypeHash() const requires (CHashable) { return NAMESPACE_REDCRAFT::GetTypeHash(Get()); } @@ -69,7 +69,7 @@ private: // Optimize TOptional with these hacking constexpr TReferenceWrapper(FInvalid) : Pointer(nullptr) { }; - template requires CDestructible friend class TOptional; + template requires (CDestructible) friend class TOptional; }; @@ -155,13 +155,13 @@ public: constexpr TOptional(FInvalid) : TOptional() { } - template requires CConstructibleFrom + template requires (CConstructibleFrom) constexpr explicit TOptional(FInPlace, Ts&&... Args) : Reference(Forward(Args)...) { } - template requires CConstructibleFrom - && (!CSameAs, FInPlace>) && (!CSameAs, TOptional>) + template requires (CConstructibleFrom + && !CSameAs, FInPlace> && !CSameAs, TOptional>) constexpr explicit (!CConvertibleTo) TOptional(T&& InValue) : TOptional(InPlace, Forward(InValue)) { } @@ -169,7 +169,7 @@ public: TOptional(const TOptional& InValue) = default; TOptional(TOptional&& InValue) = default; - template requires CConstructibleFrom && TAllowUnwrapping::Value + template requires (CConstructibleFrom && TAllowUnwrapping::Value) constexpr explicit (!CConvertibleTo) TOptional(const TOptional& InValue) : Reference(InValue.Reference) { } @@ -179,22 +179,22 @@ public: TOptional& operator=(const TOptional& InValue) = default; TOptional& operator=(TOptional&& InValue) = default; - template requires CConstructibleFrom - && CAssignableFrom && TAllowUnwrapping::Value + template requires (CConstructibleFrom + && CAssignableFrom && TAllowUnwrapping::Value) constexpr TOptional& operator=(const TOptional& InValue) { Reference = InValue.Reference; return *this; } - template requires CConstructibleFrom && CAssignableFrom + template requires (CConstructibleFrom && CAssignableFrom) constexpr TOptional& operator=(T&& InValue) { Reference = InValue; return *this; } - template requires CConstructibleFrom + template requires (CConstructibleFrom) constexpr OptionalType& Emplace(ArgTypes&&... Args) { Reference = TReferenceWrapper(Forward(Args)...); @@ -225,7 +225,7 @@ public: Reference = Invalid; } - constexpr size_t GetTypeHash() const requires CHashable + constexpr size_t GetTypeHash() const requires (CHashable) { if (!IsValid()) return 2824517378; return Reference.GetTypeHash(); @@ -239,7 +239,7 @@ public: private: TReferenceWrapper Reference; - template requires CDestructible friend class TOptional; + template requires (CDestructible) friend class TOptional; }; diff --git a/Redcraft.Utility/Source/Public/Templates/Tuple.h b/Redcraft.Utility/Source/Public/Templates/Tuple.h index 1a7a5c1..31d3f73 100644 --- a/Redcraft.Utility/Source/Public/Templates/Tuple.h +++ b/Redcraft.Utility/Source/Public/Templates/Tuple.h @@ -312,22 +312,22 @@ public: TTuple() = default; - template requires (sizeof...(Ts) >= 1) && (sizeof...(ArgTypes) == sizeof...(Ts)) + 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...(Ts)) + template requires (sizeof...(OtherTypes) == sizeof...(Ts) && (true && ... && CConstructibleFrom) - && NAMESPACE_PRIVATE::TTupleConvertCopy::Value + && NAMESPACE_PRIVATE::TTupleConvertCopy::Value) constexpr explicit (!(true && ... && CConvertibleTo)) TTuple(const TTuple& InValue) : Super(NAMESPACE_PRIVATE::OtherTupleConstructor, InValue) { } - template requires (sizeof...(OtherTypes) == sizeof...(Ts)) + template requires (sizeof...(OtherTypes) == sizeof...(Ts) && (true && ... && CConstructibleFrom) - && NAMESPACE_PRIVATE::TTupleConvertMove::Value + && NAMESPACE_PRIVATE::TTupleConvertMove::Value) constexpr explicit (!(true && ... && CConvertibleTo)) TTuple(TTuple&& InValue) : Super(NAMESPACE_PRIVATE::OtherTupleConstructor, MoveTemp(InValue)) { } @@ -335,16 +335,16 @@ public: TTuple(const TTuple&) = default; TTuple(TTuple&&) = default; - template requires (sizeof...(OtherTypes) == sizeof...(Ts)) - && (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...(Ts)) - && (true && ... && CAssignableFrom) + template requires (sizeof...(OtherTypes) == sizeof...(Ts) + && (true && ... && CAssignableFrom)) constexpr TTuple& operator=(TTuple&& InValue) { Helper::Assign(*this, MoveTemp(InValue)); @@ -372,32 +372,32 @@ public: 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)); } @@ -408,14 +408,14 @@ public: 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) { @@ -593,21 +593,21 @@ constexpr decltype(auto) TupleCat(TTupleTypes&&... Args) else return NAMESPACE_PRIVATE::TTupleCatImpl::F(Forward(Args)...); } -template requires ((sizeof...(LHSTypes) != sizeof...(RHSTypes)) || (true && ... && CWeaklyEqualityComparable)) +template requires (sizeof...(LHSTypes) != sizeof...(RHSTypes) || (true && ... && CWeaklyEqualityComparable)) constexpr bool operator==(const TTuple& LHS, const TTuple& RHS) { if constexpr (sizeof...(LHSTypes) != sizeof...(RHSTypes)) return false; return[&LHS, &RHS](TIndexSequence) -> bool { return (true && ... && (LHS.template GetValue() == RHS.template GetValue())); } (TMakeIndexSequence()); } -template requires ((sizeof...(LHSTypes) == sizeof...(RHSTypes)) && (true && ... && (CSynthThreeWayComparable))) +template requires (sizeof...(LHSTypes) == sizeof...(RHSTypes) && (true && ... && (CSynthThreeWayComparable))) constexpr TCommonComparisonCategory...> operator<=>(const TTuple& LHS, const TTuple& RHS) { using R = TCommonComparisonCategory...>; return NAMESPACE_PRIVATE::TTupleThreeWay>::F(LHS, RHS); } -template requires CInvocable +template requires (CInvocable) constexpr void VisitTuple(F&& Func) { } template @@ -617,14 +617,14 @@ constexpr void VisitTuple(F&& Func, FirstTupleType&& FirstTuple, TupleTypes&&... ::F(Forward(Func), Forward(FirstTuple), Forward(Tuples)...); } -template requires requires { typename TTuple...>; } +template requires (requires { typename TTuple...>; }) struct TBasicCommonType, TTuple> { using Type = TTuple...>; }; template typename TQualifiers, template typename UQualifiers> - requires requires { typename TTuple, UQualifiers>...>; } + requires (requires { typename TTuple, UQualifiers>...>; }) struct TBasicCommonReference, TTuple, TQualifiers, UQualifiers> { using Type = TTuple, UQualifiers>...>; diff --git a/Redcraft.Utility/Source/Public/Templates/TypeHash.h b/Redcraft.Utility/Source/Public/Templates/TypeHash.h index 051512a..10bea77 100644 --- a/Redcraft.Utility/Source/Public/Templates/TypeHash.h +++ b/Redcraft.Utility/Source/Public/Templates/TypeHash.h @@ -46,7 +46,7 @@ constexpr size_t HashCombine(size_t A, size_t C, Ts... InOther) return HashCombine(B, InOther...); } -template requires CIntegral +template constexpr size_t GetTypeHash(T A) { static_assert(sizeof(T) <= 16, "GetTypeHash only works with T up to 128 bits."); @@ -59,7 +59,7 @@ constexpr size_t GetTypeHash(T A) return INDEX_NONE; } -template requires CFloatingPoint +template constexpr size_t GetTypeHash(T A) { static_assert(sizeof(T) <= 16, "GetTypeHash only works with T up to 128 bits."); @@ -74,25 +74,25 @@ constexpr size_t GetTypeHash(T A) return INDEX_NONE; } -template requires CEnum +template constexpr size_t GetTypeHash(T A) { return GetTypeHash(static_cast>(A)); } -template requires CPointer || CSameAs +template requires (CPointer || CSameAs) constexpr size_t GetTypeHash(T A) { return GetTypeHash(reinterpret_cast(A)); } -template requires requires(const T& A) { { GetTypeHash(A.GetTypeHash()) } -> CSameAs; } +template requires (requires(const T& A) { { GetTypeHash(A.GetTypeHash()) } -> CSameAs; }) constexpr size_t GetTypeHash(const T& A) { return GetTypeHash(A.GetTypeHash()); } -template requires requires(const T& A) { { GetTypeHash(A.hash_code()) } -> CSameAs; } +template requires (requires(const T& A) { { GetTypeHash(A.hash_code()) } -> CSameAs; }) constexpr size_t GetTypeHash(const T& A) { return GetTypeHash(A.hash_code()); diff --git a/Redcraft.Utility/Source/Public/Templates/Utility.h b/Redcraft.Utility/Source/Public/Templates/Utility.h index d76e814..ad427c2 100644 --- a/Redcraft.Utility/Source/Public/Templates/Utility.h +++ b/Redcraft.Utility/Source/Public/Templates/Utility.h @@ -55,8 +55,8 @@ constexpr T&& Forward(TRemoveReference&& Obj) return static_cast(Obj); } -template requires requires(T& A, T& B) { A.Swap(B); } - || (CMoveConstructible && CMoveAssignable) +template requires (requires(T& A, T& B) { A.Swap(B); } + || (CMoveConstructible && CMoveAssignable)) constexpr void Swap(T& A, T& B) { if constexpr (requires(T& A, T& B) { A.Swap(B); }) @@ -71,7 +71,7 @@ constexpr void Swap(T& A, T& B) } } -template requires CMoveConstructible && CAssignableFrom +template requires (CMoveConstructible && CAssignableFrom) constexpr T Exchange(T& A, U&& B) { T Temp = MoveTemp(A); @@ -82,7 +82,7 @@ constexpr T Exchange(T& A, U&& B) template constexpr T&& DeclVal(); -template requires CObject +template requires (CObject) constexpr T* AddressOf(T& Object) { return reinterpret_cast(&const_cast(reinterpret_cast(Object))); diff --git a/Redcraft.Utility/Source/Public/Templates/Variant.h b/Redcraft.Utility/Source/Public/Templates/Variant.h index 293063e..fe953f9 100644 --- a/Redcraft.Utility/Source/Public/Templates/Variant.h +++ b/Redcraft.Utility/Source/Public/Templates/Variant.h @@ -159,8 +159,8 @@ public: if (IsValid()) MoveConstructImpl[InValue.GetIndex()](&Value, &InValue.Value); } - template requires (I < sizeof...(Ts)) - && CConstructibleFrom>, ArgTypes...> + template requires (I < sizeof...(Ts) + && CConstructibleFrom>, ArgTypes...>) constexpr explicit TVariant(TInPlaceIndex, ArgTypes&&... Args) : TypeIndex(I) { @@ -168,14 +168,14 @@ public: new(&Value) SelectedType(Forward(Args)...); } - template requires CConstructibleFrom + template requires (CConstructibleFrom) constexpr explicit TVariant(TInPlaceType, ArgTypes&&... Args) : TVariant(InPlaceIndex>>, Forward(Args)...) { } - template requires NAMESPACE_PRIVATE::TVariantSelectedType, Ts...>::Value - && (!CTInPlaceType>) && (!CTInPlaceIndex>) - && (!CSameAs, TVariant>) + template requires (NAMESPACE_PRIVATE::TVariantSelectedType, Ts...>::Value + && !CTInPlaceType> && !CTInPlaceIndex> + && !CSameAs, TVariant>) constexpr TVariant(T&& InValue) : TVariant(InPlaceType, Ts...>::Type>, Forward(InValue)) { } @@ -226,7 +226,7 @@ public: return *this; } - template requires NAMESPACE_PRIVATE::TVariantSelectedType, Ts...>::Value + template requires (NAMESPACE_PRIVATE::TVariantSelectedType, Ts...>::Value) constexpr TVariant& operator=(T&& InValue) { using SelectedType = typename NAMESPACE_PRIVATE::TVariantSelectedType, Ts...>::Type; @@ -242,8 +242,8 @@ public: return *this; } - template requires (I < sizeof...(Ts)) - && CConstructibleFrom>, ArgTypes...> + template requires (I < sizeof...(Ts) + && CConstructibleFrom>, ArgTypes...>) constexpr TVariantAlternative>& Emplace(ArgTypes&&... Args) { Reset(); @@ -255,7 +255,7 @@ public: return *Result; } - template requires CConstructibleFrom + template requires (CConstructibleFrom) constexpr T& Emplace(ArgTypes&&... Args) { return Emplace>>(Forward(Args)...); @@ -423,7 +423,7 @@ private: 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()); }... }; + 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, Ts...> Value; uint8 TypeIndex; @@ -452,7 +452,7 @@ private: }; -template requires (!CSameAs>) && CEqualityComparable +template requires (!CSameAs> && CEqualityComparable) constexpr bool operator==(const TVariant& LHS, const T& RHS) { return LHS.template HoldsAlternative() ? LHS.template GetValue() == RHS : false; diff --git a/Redcraft.Utility/Source/Public/TypeTraits/Common.h b/Redcraft.Utility/Source/Public/TypeTraits/Common.h index ee711cb..7ab2502 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/Common.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/Common.h @@ -135,7 +135,7 @@ template concept CCommonTypeImpl = requires { typename template requires (!CSimpleCommonReference && !CBasicCommonReference && !CConditionalValType && CCommonTypeImpl) struct TCommonReferenceImpl : TCommonTypeImpl { }; -// Otherwise, there is no member Type. +// Otherwise, there is no member Type // If sizeof...(Ts) is greater than two @@ -143,7 +143,7 @@ struct TCommonReferenceImpl : TCommonTypeImpl { }; template requires (requires { typename TCommonReferenceImpl::Type; }) struct TCommonReferenceImpl : TCommonReferenceImpl::Type, W, Ts...> { }; -// In all other cases, there is no member Type. +// In all other cases, there is no member Type template struct TCommonReferenceImpl { }; @@ -166,7 +166,7 @@ template requires (CConvertibleTo { using Type = typename TSimpleCommonReferenceImpl::Type; }; template struct TSimpleCommonReferenceImpl : TSimpleCommonReferenceImpl { }; // The order is not important -// Otherwise, there's no simple common reference Type. +// Otherwise, there's no simple common reference Type template struct TSimpleCommonReferenceImpl { };