diff --git a/Redcraft.Utility/Source/Public/Memory/Alignment.h b/Redcraft.Utility/Source/Public/Memory/Alignment.h index 8e5f724..c24767a 100644 --- a/Redcraft.Utility/Source/Public/Memory/Alignment.h +++ b/Redcraft.Utility/Source/Public/Memory/Alignment.h @@ -10,7 +10,7 @@ NAMESPACE_MODULE_BEGIN(Utility) NAMESPACE_BEGIN(Memory) -constexpr bool IsValidAlignment(size_t Alignment) { return !(Alignment & (Alignment - 1)); } +FORCEINLINE constexpr bool IsValidAlignment(size_t Alignment) { return !(Alignment & (Alignment - 1)); } template requires (CIntegral || CPointer) FORCEINLINE constexpr T Align(T InValue, size_t Alignment) diff --git a/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h b/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h index ef7d3a1..e4b8c99 100644 --- a/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h +++ b/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h @@ -63,7 +63,7 @@ template concept CSynthThreeWayComparable = CThreeWayComparable || CTotallyOrdered; template requires (CSynthThreeWayComparable) -constexpr decltype(auto) SynthThreeWayCompare(T&& LHS, U&& RHS) +FORCEINLINE constexpr decltype(auto) SynthThreeWayCompare(T&& LHS, U&& RHS) { if constexpr (CThreeWayComparable) { diff --git a/Redcraft.Utility/Source/Public/Templates/Atomic.h b/Redcraft.Utility/Source/Public/Templates/Atomic.h index 6ad66f5..00d6bb9 100644 --- a/Redcraft.Utility/Source/Public/Templates/Atomic.h +++ b/Redcraft.Utility/Source/Public/Templates/Atomic.h @@ -68,8 +68,8 @@ public: static constexpr size_t RequiredAlignment = NAMESPACE_STD::atomic_ref::required_alignment; - constexpr TAtomicImpl() requires (!bIsRef) : NativeAtomic() { }; - constexpr TAtomicImpl(ValueType Desired) requires (!bIsRef) : NativeAtomic(Desired) { }; + FORCEINLINE constexpr TAtomicImpl() requires (!bIsRef) : NativeAtomic() { }; + FORCEINLINE constexpr TAtomicImpl(ValueType Desired) requires (!bIsRef) : NativeAtomic(Desired) { }; FORCEINLINE explicit TAtomicImpl(ValueType& Desired) requires (bIsRef) : NativeAtomic(Desired) { check(Memory::IsAligned(&Desired, RequiredAlignment)); }; FORCEINLINE TAtomicImpl(TAtomicImpl& InValue) requires (bIsRef) : NativeAtomic(InValue) { }; @@ -247,7 +247,7 @@ struct FAtomicFlag : FSingleton { public: - constexpr FAtomicFlag() : NativeAtomic() { }; + FORCEINLINE constexpr FAtomicFlag() : NativeAtomic() { }; FORCEINLINE void Clear(EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) { MEMORY_ORDER_CHECK(Order, 0x01 | 0x08 | 0x20); NativeAtomic.clear(static_cast(Order)); } FORCEINLINE void Clear(EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile { MEMORY_ORDER_CHECK(Order, 0x01 | 0x08 | 0x20); NativeAtomic.clear(static_cast(Order)); } diff --git a/Redcraft.Utility/Source/Public/Templates/Container.h b/Redcraft.Utility/Source/Public/Templates/Container.h index b047074..083e4e2 100644 --- a/Redcraft.Utility/Source/Public/Templates/Container.h +++ b/Redcraft.Utility/Source/Public/Templates/Container.h @@ -7,47 +7,47 @@ NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) template requires (requires(T&& Container) { Container.GetData(); }) -constexpr decltype(auto) GetData(T&& Container) +FORCEINLINE constexpr decltype(auto) GetData(T&& Container) { return Container.GetData(); } -template constexpr T* GetData( T(& Container)[N]) { return Container; } -template constexpr T* GetData( T(&& Container)[N]) { return Container; } -template constexpr const T* GetData(const T(& Container)[N]) { return Container; } -template constexpr const T* GetData(const T(&& Container)[N]) { return Container; } +template FORCEINLINE constexpr T* GetData( T(& Container)[N]) { return Container; } +template FORCEINLINE constexpr T* GetData( T(&& Container)[N]) { return Container; } +template FORCEINLINE constexpr const T* GetData(const T(& Container)[N]) { return Container; } +template FORCEINLINE constexpr const T* GetData(const T(&& Container)[N]) { return Container; } template requires (requires(T&& Container) { Container.data(); }) -constexpr decltype(auto) GetData(T&& Container) +FORCEINLINE constexpr decltype(auto) GetData(T&& Container) { return Container.data(); } template -constexpr decltype(auto) GetData(initializer_list Container) +FORCEINLINE constexpr decltype(auto) GetData(initializer_list Container) { return Container.begin(); } template requires (requires(T&& Container) { Container.Num(); }) -constexpr decltype(auto) GetNum(T&& Container) +FORCEINLINE constexpr decltype(auto) GetNum(T&& Container) { return Container.Num(); } -template constexpr size_t GetNum( T(& Container)[N]) { return N; } -template constexpr size_t GetNum( T(&& Container)[N]) { return N; } -template constexpr size_t GetNum(const T(& Container)[N]) { return N; } -template constexpr size_t GetNum(const T(&& Container)[N]) { return N; } +template FORCEINLINE constexpr size_t GetNum( T(& Container)[N]) { return N; } +template FORCEINLINE constexpr size_t GetNum( T(&& Container)[N]) { return N; } +template FORCEINLINE constexpr size_t GetNum(const T(& Container)[N]) { return N; } +template FORCEINLINE constexpr size_t GetNum(const T(&& Container)[N]) { return N; } template requires (requires(T&& Container) { Container.size(); }) -constexpr decltype(auto) GetNum(T&& Container) +FORCEINLINE constexpr decltype(auto) GetNum(T&& Container) { return Container.size(); } template -constexpr decltype(auto) GetNum(initializer_list Container) +FORCEINLINE constexpr decltype(auto) GetNum(initializer_list Container) { return Container.size(); } diff --git a/Redcraft.Utility/Source/Public/Templates/Function.h b/Redcraft.Utility/Source/Public/Templates/Function.h index 04bef52..5f59c90 100644 --- a/Redcraft.Utility/Source/Public/Templates/Function.h +++ b/Redcraft.Utility/Source/Public/Templates/Function.h @@ -54,34 +54,34 @@ class TFunctionStorage { public: - constexpr TFunctionStorage() = default; - constexpr TFunctionStorage(const TFunctionStorage&) = default; - constexpr TFunctionStorage(TFunctionStorage&&) = default; - constexpr TFunctionStorage& operator=(const TFunctionStorage&) = delete; - constexpr TFunctionStorage& operator=(TFunctionStorage&&) = delete; - constexpr ~TFunctionStorage() = default; + FORCEINLINE constexpr TFunctionStorage() = default; + FORCEINLINE constexpr TFunctionStorage(const TFunctionStorage&) = default; + FORCEINLINE constexpr TFunctionStorage(TFunctionStorage&&) = default; + FORCEINLINE constexpr TFunctionStorage& operator=(const TFunctionStorage&) = delete; + FORCEINLINE constexpr TFunctionStorage& operator=(TFunctionStorage&&) = delete; + FORCEINLINE constexpr ~TFunctionStorage() = default; - constexpr uintptr GetValuePtr() const { return ValuePtr; } - constexpr uintptr GetCallable() const { return Callable; } + FORCEINLINE constexpr uintptr GetValuePtr() const { return ValuePtr; } + FORCEINLINE constexpr uintptr GetCallable() const { return Callable; } - constexpr bool IsValid() const { return ValuePtr != 0; } + FORCEINLINE constexpr bool IsValid() const { return ValuePtr != 0; } // Use Invalidate() to invalidate the storage or use Emplace() to emplace a new object after destruction. - constexpr void Destroy() { } + FORCEINLINE constexpr void Destroy() { } // Make sure you call this function after you have destroyed the held object using Destroy(). - constexpr void Invalidate() { ValuePtr = 0; } + FORCEINLINE constexpr void Invalidate() { ValuePtr = 0; } // Make sure you call this function after you have destroyed the held object using Destroy(). template - constexpr void Emplace(intptr InCallable, U&& Args) + FORCEINLINE constexpr void Emplace(intptr InCallable, U&& Args) { static_assert(CSameAs, TDecay>); ValuePtr = reinterpret_cast(AddressOf(Args)); Callable = InCallable; } - constexpr void Swap(TFunctionStorage& InValue) + FORCEINLINE constexpr void Swap(TFunctionStorage& InValue) { NAMESPACE_REDCRAFT::Swap(ValuePtr, InValue.ValuePtr); NAMESPACE_REDCRAFT::Swap(Callable, InValue.Callable); @@ -101,7 +101,7 @@ class alignas(16) TFunctionStorage { public: - constexpr TFunctionStorage() = default; + FORCEINLINE constexpr TFunctionStorage() = default; FORCEINLINE TFunctionStorage(const TFunctionStorage& InValue) requires (!bIsUnique) : TypeInfo(InValue.TypeInfo) @@ -232,10 +232,10 @@ public: return *this; } - constexpr uintptr GetValuePtr() const { return reinterpret_cast(GetStorage()); } - constexpr uintptr GetCallable() const { return Callable; } + FORCEINLINE constexpr uintptr GetValuePtr() const { return reinterpret_cast(GetStorage()); } + FORCEINLINE constexpr uintptr GetCallable() const { return Callable; } - constexpr bool IsValid() const { return TypeInfo != 0; } + FORCEINLINE constexpr bool IsValid() const { return TypeInfo != 0; } // Use Invalidate() to invalidate the storage or use Emplace() to emplace a new object after destruction. FORCEINLINE void Destroy() @@ -259,7 +259,7 @@ public: } // Make sure you call this function after you have destroyed the held object using Destroy(). - constexpr void Invalidate() { TypeInfo = 0; } + FORCEINLINE constexpr void Invalidate() { TypeInfo = 0; } // Make sure you call this function after you have destroyed the held object using Destroy(). template @@ -342,7 +342,7 @@ private: const FDestruct Destruct; template - constexpr FMovableTypeInfo(TInPlaceType) + FORCEINLINE constexpr FMovableTypeInfo(TInPlaceType) : TypeSize(sizeof(T)), TypeAlignment(alignof(T)) , MoveConstruct( [](void* A, void* B) @@ -366,7 +366,7 @@ private: const FCopyConstruct CopyConstruct; template - constexpr FCopyableTypeInfo(TInPlaceType) + FORCEINLINE constexpr FCopyableTypeInfo(TInPlaceType) : FMovableTypeInfo(InPlaceType) , CopyConstruct( [](void* A, const void* B) @@ -391,16 +391,16 @@ private: Big = 3, // ExternalStorage }; - constexpr ERepresentation GetRepresentation() const { return static_cast(TypeInfo & RepresentationMask); } - constexpr const FTypeInfo& GetTypeInfo() const { return *reinterpret_cast(TypeInfo & ~RepresentationMask); } + FORCEINLINE constexpr ERepresentation GetRepresentation() const { return static_cast(TypeInfo & RepresentationMask); } + FORCEINLINE constexpr const FTypeInfo& GetTypeInfo() const { return *reinterpret_cast(TypeInfo & ~RepresentationMask); } - constexpr void* GetStorage() { return GetRepresentation() == ERepresentation::Trivial || GetRepresentation() == ERepresentation::Small ? InternalStorage : ExternalStorage; } - constexpr const void* GetStorage() const { return GetRepresentation() == ERepresentation::Trivial || GetRepresentation() == ERepresentation::Small ? InternalStorage : ExternalStorage; } + FORCEINLINE constexpr void* GetStorage() { return GetRepresentation() == ERepresentation::Trivial || GetRepresentation() == ERepresentation::Small ? InternalStorage : ExternalStorage; } + FORCEINLINE constexpr const void* GetStorage() const { return GetRepresentation() == ERepresentation::Trivial || GetRepresentation() == ERepresentation::Small ? InternalStorage : ExternalStorage; } }; template -constexpr bool FunctionIsBound(const T& Func) +FORCEINLINE constexpr bool FunctionIsBound(const T& Func) { if constexpr (CPointer || CMemberPointer || CTFunctionRef || CTFunction || CTUniqueFunction) { @@ -448,12 +448,12 @@ public: using ResultType = Ret; using ArgumentType = TTypeSequence; - constexpr TFunctionImpl() = default; - constexpr TFunctionImpl(const TFunctionImpl&) = default; - constexpr TFunctionImpl(TFunctionImpl&&) = default; - constexpr TFunctionImpl& operator=(const TFunctionImpl&) = default; - constexpr TFunctionImpl& operator=(TFunctionImpl&&) = default; - constexpr ~TFunctionImpl() = default; + FORCEINLINE constexpr TFunctionImpl() = default; + FORCEINLINE constexpr TFunctionImpl(const TFunctionImpl&) = default; + FORCEINLINE constexpr TFunctionImpl(TFunctionImpl&&) = default; + FORCEINLINE constexpr TFunctionImpl& operator=(const TFunctionImpl&) = default; + FORCEINLINE constexpr TFunctionImpl& operator=(TFunctionImpl&&) = default; + FORCEINLINE constexpr ~TFunctionImpl() = default; FORCEINLINE ResultType operator()(Ts... Args) requires (CSameAs) { return CallImpl(Forward(Args)...); } FORCEINLINE ResultType operator()(Ts... Args) & requires (CSameAs) { return CallImpl(Forward(Args)...); } @@ -462,10 +462,10 @@ public: FORCEINLINE ResultType operator()(Ts... Args) const& requires (CSameAs) { return CallImpl(Forward(Args)...); } FORCEINLINE ResultType operator()(Ts... Args) const&& requires (CSameAs) { return CallImpl(Forward(Args)...); } - constexpr bool IsValid() const { return Storage.IsValid(); } - constexpr explicit operator bool() const { return Storage.IsValid(); } + FORCEINLINE constexpr bool IsValid() const { return Storage.IsValid(); } + FORCEINLINE constexpr explicit operator bool() const { return Storage.IsValid(); } - constexpr void Swap(TFunctionImpl& InValue) { Storage.Swap(InValue.Storage); } + FORCEINLINE constexpr void Swap(TFunctionImpl& InValue) { Storage.Swap(InValue.Storage); } private: @@ -483,14 +483,14 @@ private: protected: // These functions should not be used by user-defined class // Use Invalidate() to invalidate the storage or use Emplace() to emplace a new object after destruction. - FORCEINLINE void Destroy() { Storage.Destroy(); } + FORCEINLINE constexpr void Destroy() { Storage.Destroy(); } // Make sure you call this function after you have destroyed the held object using Destroy(). - constexpr void Invalidate() { Storage.Invalidate(); } + FORCEINLINE constexpr void Invalidate() { Storage.Invalidate(); } // Make sure you call this function after you have destroyed the held object using Destroy(). template - FORCEINLINE TDecay& Emplace(ArgTypes&&... Args) + FORCEINLINE constexpr TDecay& Emplace(ArgTypes&&... Args) { using DecayedType = TDecay; @@ -534,20 +534,20 @@ private: public: - TFunctionRef() = delete; + FORCEINLINE constexpr TFunctionRef() = delete; - TFunctionRef(const TFunctionRef& InValue) = default; - TFunctionRef(TFunctionRef&& InValue) = default; + FORCEINLINE constexpr TFunctionRef(const TFunctionRef& InValue) = default; + FORCEINLINE constexpr TFunctionRef(TFunctionRef&& InValue) = default; // We delete the assignment operators because we don't want it to be confused with being related to // regular C++ reference assignment - i.e. calling the assignment operator of whatever the reference // is bound to - because that's not what TFunctionRef does, nor is it even capable of doing that. - TFunctionRef& operator=(const TFunctionRef& InValue) = delete; - TFunctionRef& operator=(TFunctionRef&& InValue) = delete; + FORCEINLINE constexpr TFunctionRef& operator=(const TFunctionRef& InValue) = delete; + FORCEINLINE constexpr TFunctionRef& operator=(TFunctionRef&& InValue) = delete; template requires (!CTFunctionRef> && NAMESPACE_PRIVATE::TIsInvocableSignature>::Value) - FORCEINLINE TFunctionRef(T&& InValue) + FORCEINLINE constexpr TFunctionRef(T&& InValue) { checkf(NAMESPACE_PRIVATE::FunctionIsBound(InValue), TEXT("Cannot bind a null/unbound callable to a TFunctionRef")); Impl::template Emplace(Forward(InValue)); @@ -571,7 +571,7 @@ private: public: - constexpr TFunction(nullptr_t = nullptr) { Impl::Invalidate(); } + FORCEINLINE constexpr TFunction(nullptr_t = nullptr) { Impl::Invalidate(); } FORCEINLINE TFunction(const TFunction& InValue) = default; FORCEINLINE TFunction(TFunction&& InValue) = default; @@ -592,12 +592,12 @@ public: template requires (NAMESPACE_PRIVATE::TIsInvocableSignature>::Value && CConstructibleFrom, ArgTypes...> && CCopyConstructible> && CMoveConstructible> && CDestructible>) - FORCEINLINE TFunction(TInPlaceType, ArgTypes&&... Args) + FORCEINLINE explicit TFunction(TInPlaceType, ArgTypes&&... Args) { Impl::template Emplace(Forward(Args)...); } - constexpr TFunction& operator=(nullptr_t) { Reset(); return *this; } + FORCEINLINE constexpr TFunction& operator=(nullptr_t) { Reset(); return *this; } template requires (NAMESPACE_PRIVATE::TIsInvocableSignature>::Value && !CTFunctionRef> && !CTFunction> && !CTUniqueFunction> @@ -620,7 +620,7 @@ public: return Impl::template Emplace(Forward(Args)...); } - constexpr void Reset() { Impl::Destroy(); Impl::Invalidate(); } + FORCEINLINE constexpr void Reset() { Impl::Destroy(); Impl::Invalidate(); } }; @@ -640,7 +640,7 @@ private: public: - constexpr TUniqueFunction(nullptr_t = nullptr) { Impl::Invalidate(); } + FORCEINLINE constexpr TUniqueFunction(nullptr_t = nullptr) { Impl::Invalidate(); } FORCEINLINE TUniqueFunction(const TUniqueFunction& InValue) = delete; FORCEINLINE TUniqueFunction(TUniqueFunction&& InValue) = default; @@ -681,12 +681,12 @@ public: template requires (NAMESPACE_PRIVATE::TIsInvocableSignature>::Value && CConstructibleFrom, ArgTypes...> && CMoveConstructible> && CDestructible>) - FORCEINLINE TUniqueFunction(TInPlaceType, ArgTypes&&... Args) + FORCEINLINE explicit TUniqueFunction(TInPlaceType, ArgTypes&&... Args) { Impl::template Emplace(Forward(Args)...); } - constexpr TUniqueFunction& operator=(nullptr_t) { Impl::Destroy(); Impl::Invalidate(); return *this; } + FORCEINLINE constexpr TUniqueFunction& operator=(nullptr_t) { Impl::Destroy(); Impl::Invalidate(); return *this; } template requires (NAMESPACE_PRIVATE::TIsInvocableSignature>::Value && !CTFunctionRef> && !CTFunction> && !CTUniqueFunction> @@ -708,24 +708,24 @@ public: return Impl::template Emplace(Forward(Args)...); } - constexpr void Reset() { Impl::Destroy(); Impl::Invalidate(); } + FORCEINLINE constexpr void Reset() { Impl::Destroy(); Impl::Invalidate(); } }; template -constexpr bool operator==(const TFunctionRef& LHS, nullptr_t) +FORCEINLINE constexpr bool operator==(const TFunctionRef& LHS, nullptr_t) { return !LHS; } template -constexpr bool operator==(const TFunction& LHS, nullptr_t) +FORCEINLINE constexpr bool operator==(const TFunction& LHS, nullptr_t) { return !LHS; } template -constexpr bool operator==(const TUniqueFunction& LHS, nullptr_t) +FORCEINLINE constexpr bool operator==(const TUniqueFunction& LHS, nullptr_t) { return !LHS; } @@ -743,35 +743,29 @@ struct TNotFunction { F Storage; - TNotFunction(const TNotFunction&) = default; - TNotFunction(TNotFunction&&) = default; - - template - constexpr TNotFunction(InF&& InFunc) : Storage(Forward(InFunc)) { } - template requires (CInvocable) - constexpr auto operator()(Ts&&... Args) & + FORCEINLINE constexpr auto operator()(Ts&&... Args) & -> decltype(!Invoke(Storage, Forward(Args)...)) { return !Invoke(Storage, Forward(Args)...); } template requires (CInvocable) - constexpr auto operator()(Ts&&... Args) && + FORCEINLINE constexpr auto operator()(Ts&&... Args) && -> decltype(!Invoke(MoveTemp(Storage), Forward(Args)...)) { return !Invoke(MoveTemp(Storage), Forward(Args)...); } template requires (CInvocable) - constexpr auto operator()(Ts&&... Args) const& + FORCEINLINE constexpr auto operator()(Ts&&... Args) const& -> decltype(!Invoke(Storage, Forward(Args)...)) { return !Invoke(Storage, Forward(Args)...); } template requires (CInvocable) - constexpr auto operator()(Ts&&... Args) const&& + FORCEINLINE constexpr auto operator()(Ts&&... Args) const&& -> decltype(!Invoke(MoveTemp(Storage), Forward(Args)...)) { return !Invoke(MoveTemp(Storage), Forward(Args)...); @@ -781,9 +775,9 @@ struct TNotFunction NAMESPACE_PRIVATE_END template requires (CConstructibleFrom) -constexpr NAMESPACE_PRIVATE::TNotFunction> NotFn(F&& Func) +FORCEINLINE constexpr NAMESPACE_PRIVATE::TNotFunction> NotFn(F&& Func) { - return NAMESPACE_PRIVATE::TNotFunction>(Forward(Func)); + return { Forward(Func) }; } NAMESPACE_MODULE_END(Utility) diff --git a/Redcraft.Utility/Source/Public/Templates/Invoke.h b/Redcraft.Utility/Source/Public/Templates/Invoke.h index 3653de3..d46f83b 100644 --- a/Redcraft.Utility/Source/Public/Templates/Invoke.h +++ b/Redcraft.Utility/Source/Public/Templates/Invoke.h @@ -82,14 +82,14 @@ struct InvokeImpl : InvokeMember { }; NAMESPACE_PRIVATE_END template requires (CInvocable) -constexpr auto Invoke(F&& Func, Ts&&... Args) +FORCEINLINE 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) -constexpr R InvokeResult(F&& Func, Ts&&... Args) +FORCEINLINE constexpr R InvokeResult(F&& Func, Ts&&... Args) { if constexpr (CVoid) Invoke(Forward(Func), Forward(Args)...); else return Invoke(Forward(Func), Forward(Args)...); diff --git a/Redcraft.Utility/Source/Public/Templates/Meta.h b/Redcraft.Utility/Source/Public/Templates/Meta.h index 4f7d879..8254d8b 100644 --- a/Redcraft.Utility/Source/Public/Templates/Meta.h +++ b/Redcraft.Utility/Source/Public/Templates/Meta.h @@ -13,8 +13,8 @@ template struct TIntegerSequence { using ValueType = T; - static constexpr size_t Num() { return sizeof...(Ints); } - static constexpr const T* GetData() { return NAMESPACE_REDCRAFT::GetData({ Ints... }); } + FORCEINLINE static constexpr size_t Num() { return sizeof...(Ints); } + FORCEINLINE static constexpr const T* GetData() { return NAMESPACE_REDCRAFT::GetData({ Ints... }); } }; NAMESPACE_PRIVATE_BEGIN diff --git a/Redcraft.Utility/Source/Public/Templates/Optional.h b/Redcraft.Utility/Source/Public/Templates/Optional.h index db3368b..82adf09 100644 --- a/Redcraft.Utility/Source/Public/Templates/Optional.h +++ b/Redcraft.Utility/Source/Public/Templates/Optional.h @@ -36,12 +36,12 @@ public: using ValueType = OptionalType; - constexpr TOptional() : bIsValid(false) { } + FORCEINLINE constexpr TOptional() : bIsValid(false) { } - constexpr TOptional(FInvalid) : TOptional() { } + FORCEINLINE constexpr TOptional(FInvalid) : TOptional() { } template requires (CConstructibleFrom) - constexpr explicit TOptional(FInPlace, Ts&&... Args) + FORCEINLINE constexpr explicit TOptional(FInPlace, Ts&&... Args) : bIsValid(true) { new (&Value) OptionalType(Forward(Args)...); @@ -49,50 +49,50 @@ public: template requires (CConstructibleFrom) && (!CSameAs, FInPlace>) && (!CBaseOf>) - constexpr explicit (!CConvertibleTo) TOptional(T&& InValue) + FORCEINLINE constexpr explicit (!CConvertibleTo) TOptional(T&& InValue) : TOptional(InPlace, Forward(InValue)) { } - constexpr TOptional(const TOptional& InValue) requires (CTriviallyCopyConstructible) = default; + FORCEINLINE constexpr TOptional(const TOptional& InValue) requires (CTriviallyCopyConstructible) = default; - constexpr TOptional(const TOptional& InValue) requires (CCopyConstructible && !CTriviallyCopyConstructible) + FORCEINLINE constexpr TOptional(const TOptional& InValue) requires (CCopyConstructible && !CTriviallyCopyConstructible) : bIsValid(InValue.IsValid()) { if (InValue.IsValid()) new (&Value) OptionalType(InValue.GetValue()); } - constexpr TOptional(TOptional&& InValue) requires (CTriviallyMoveConstructible) = default; + FORCEINLINE constexpr TOptional(TOptional&& InValue) requires (CTriviallyMoveConstructible) = default; - constexpr TOptional(TOptional&& InValue) requires (CMoveConstructible && !CTriviallyMoveConstructible) + FORCEINLINE constexpr TOptional(TOptional&& InValue) requires (CMoveConstructible && !CTriviallyMoveConstructible) : bIsValid(InValue.IsValid()) { if (InValue.IsValid()) new (&Value) OptionalType(MoveTemp(InValue.GetValue())); } template requires (CConstructibleFrom && TAllowUnwrapping::Value) - constexpr explicit (!CConvertibleTo) TOptional(const TOptional& InValue) + FORCEINLINE constexpr explicit (!CConvertibleTo) TOptional(const TOptional& InValue) : bIsValid(InValue.IsValid()) { if (InValue.IsValid()) new (&Value) OptionalType(InValue.GetValue()); } template requires (CConstructibleFrom && TAllowUnwrapping::Value) - constexpr explicit (!CConvertibleTo) TOptional(TOptional&& InValue) + FORCEINLINE constexpr explicit (!CConvertibleTo) TOptional(TOptional&& InValue) : bIsValid(InValue.IsValid()) { if (InValue.IsValid()) new (&Value) OptionalType(MoveTemp(InValue.GetValue())); } - constexpr ~TOptional() requires (CTriviallyDestructible) = default; + FORCEINLINE constexpr ~TOptional() requires (CTriviallyDestructible) = default; - constexpr ~TOptional() requires (!CTriviallyDestructible) + FORCEINLINE constexpr ~TOptional() requires (!CTriviallyDestructible) { Reset(); } - constexpr TOptional& operator=(const TOptional& InValue) requires (CTriviallyCopyConstructible && CTriviallyCopyAssignable) = default; + FORCEINLINE constexpr TOptional& operator=(const TOptional& InValue) requires (CTriviallyCopyConstructible && CTriviallyCopyAssignable) = default; - constexpr TOptional& operator=(const TOptional& InValue) requires (CCopyConstructible && CCopyAssignable + FORCEINLINE constexpr TOptional& operator=(const TOptional& InValue) requires (CCopyConstructible && CCopyAssignable && !CTriviallyCopyConstructible && !CTriviallyCopyAssignable) { if (&InValue == this) return *this; @@ -113,9 +113,9 @@ public: return *this; } - constexpr TOptional& operator=(TOptional&& InValue) requires (CTriviallyMoveConstructible && CTriviallyMoveAssignable) = default; + FORCEINLINE constexpr TOptional& operator=(TOptional&& InValue) requires (CTriviallyMoveConstructible && CTriviallyMoveAssignable) = default; - constexpr TOptional& operator=(TOptional&& InValue) requires (CMoveConstructible && CMoveAssignable + FORCEINLINE constexpr TOptional& operator=(TOptional&& InValue) requires (CMoveConstructible && CMoveAssignable && !CTriviallyMoveConstructible && !CTriviallyMoveAssignable) { if (&InValue == this) return *this; @@ -138,7 +138,7 @@ public: template requires (CConstructibleFrom && CAssignableFrom && TAllowUnwrapping::Value) - constexpr TOptional& operator=(const TOptional& InValue) + FORCEINLINE constexpr TOptional& operator=(const TOptional& InValue) { if (!InValue.IsValid()) { @@ -158,7 +158,7 @@ public: template requires (CConstructibleFrom && CAssignableFrom && TAllowUnwrapping::Value) - constexpr TOptional& operator=(TOptional&& InValue) + FORCEINLINE constexpr TOptional& operator=(TOptional&& InValue) { if (!InValue.IsValid()) { @@ -177,7 +177,7 @@ public: } template requires (CConstructibleFrom && CAssignableFrom) - constexpr TOptional& operator=(T&& InValue) + FORCEINLINE constexpr TOptional& operator=(T&& InValue) { if (IsValid()) GetValue() = Forward(InValue); else @@ -190,7 +190,7 @@ public: } template requires (CConstructibleFrom) - constexpr OptionalType& Emplace(ArgTypes&&... Args) + FORCEINLINE constexpr OptionalType& Emplace(ArgTypes&&... Args) { Reset(); @@ -200,26 +200,26 @@ public: return *Result; } - constexpr bool IsValid() const { return bIsValid; } - constexpr explicit operator bool() const { return bIsValid; } + FORCEINLINE constexpr bool IsValid() const { return bIsValid; } + FORCEINLINE constexpr explicit operator bool() const { return bIsValid; } - constexpr OptionalType& GetValue() & { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return *reinterpret_cast< OptionalType*>(&Value); } - constexpr OptionalType&& GetValue() && { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast< OptionalType*>(&Value)); } - constexpr const OptionalType& GetValue() const& { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return *reinterpret_cast(&Value); } - constexpr const OptionalType&& GetValue() const&& { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast(&Value)); } + FORCEINLINE constexpr OptionalType& GetValue() & { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return *reinterpret_cast< OptionalType*>(&Value); } + FORCEINLINE constexpr OptionalType&& GetValue() && { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast< OptionalType*>(&Value)); } + FORCEINLINE constexpr const OptionalType& GetValue() const& { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return *reinterpret_cast(&Value); } + FORCEINLINE constexpr const OptionalType&& GetValue() const&& { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast(&Value)); } - constexpr const OptionalType* operator->() const { return &GetValue(); } - constexpr OptionalType* operator->() { return &GetValue(); } + FORCEINLINE constexpr const OptionalType* operator->() const { return &GetValue(); } + FORCEINLINE constexpr OptionalType* operator->() { return &GetValue(); } - constexpr OptionalType& operator*() & { return GetValue(); } - constexpr OptionalType&& operator*() && { return GetValue(); } - constexpr const OptionalType& operator*() const& { return GetValue(); } - constexpr const OptionalType&& operator*() const&& { return GetValue(); } + FORCEINLINE constexpr OptionalType& operator*() & { return GetValue(); } + FORCEINLINE constexpr OptionalType&& operator*() && { return GetValue(); } + FORCEINLINE constexpr const OptionalType& operator*() const& { return GetValue(); } + FORCEINLINE constexpr const OptionalType&& operator*() const&& { return GetValue(); } - constexpr OptionalType& Get( OptionalType& DefaultValue) & { return IsValid() ? GetValue() : DefaultValue; } - constexpr const OptionalType& Get(const OptionalType& DefaultValue) const& { return IsValid() ? GetValue() : DefaultValue; } + FORCEINLINE constexpr OptionalType& Get( OptionalType& DefaultValue) & { return IsValid() ? GetValue() : DefaultValue; } + FORCEINLINE constexpr const OptionalType& Get(const OptionalType& DefaultValue) const& { return IsValid() ? GetValue() : DefaultValue; } - constexpr void Reset() + FORCEINLINE constexpr void Reset() { if (bIsValid) { @@ -230,14 +230,14 @@ public: } } - constexpr size_t GetTypeHash() const requires (CHashable) + FORCEINLINE constexpr size_t GetTypeHash() const requires (CHashable) { if (!IsValid()) return 2824517378; return NAMESPACE_REDCRAFT::GetTypeHash(GetValue()); } template requires (CMoveConstructible && CSwappable) - constexpr void Swap(TOptional& InValue) + FORCEINLINE constexpr void Swap(TOptional& InValue) { if (!IsValid() && !InValue.IsValid()) return; @@ -269,7 +269,7 @@ template TOptional(T) -> TOptional; template requires (CWeaklyEqualityComparable) -constexpr bool operator==(const TOptional& LHS, const TOptional& RHS) +FORCEINLINE constexpr bool operator==(const TOptional& LHS, const TOptional& RHS) { if (LHS.IsValid() != RHS.IsValid()) return false; if (LHS.IsValid() == false) return true; @@ -277,7 +277,7 @@ constexpr bool operator==(const TOptional& LHS, const TOptional& RHS) } template requires (CSynthThreeWayComparable) -constexpr partial_ordering operator<=>(const TOptional& LHS, const TOptional& RHS) +FORCEINLINE constexpr partial_ordering operator<=>(const TOptional& LHS, const TOptional& RHS) { if (LHS.IsValid() != RHS.IsValid()) return partial_ordering::unordered; if (LHS.IsValid() == false) return partial_ordering::equivalent; @@ -285,31 +285,31 @@ constexpr partial_ordering operator<=>(const TOptional& LHS, const TOptional< } template requires (CWeaklyEqualityComparable) -constexpr bool operator==(const TOptional& LHS, const U& RHS) +FORCEINLINE constexpr bool operator==(const TOptional& LHS, const U& RHS) { return LHS.IsValid() ? *LHS == RHS : false; } template -constexpr bool operator==(const TOptional& LHS, FInvalid) +FORCEINLINE constexpr bool operator==(const TOptional& LHS, FInvalid) { return !LHS.IsValid(); } template requires (CDestructible) -constexpr TOptional> MakeOptional(FInvalid) +FORCEINLINE constexpr TOptional> MakeOptional(FInvalid) { return TOptional>(Invalid); } template requires (CDestructible && CConstructibleFrom) -constexpr TOptional MakeOptional(T&& InValue) +FORCEINLINE constexpr TOptional MakeOptional(T&& InValue) { return TOptional(Forward(InValue)); } template requires (CDestructible && CConstructibleFrom) -constexpr TOptional MakeOptional(Ts&&... Args) +FORCEINLINE 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 985531e..1d20d18 100644 --- a/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h +++ b/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h @@ -18,43 +18,43 @@ public: using Type = ReferencedType; template requires (CConvertibleTo) - constexpr TReferenceWrapper(T&& Object) + FORCEINLINE constexpr TReferenceWrapper(T&& Object) { ReferencedType& Reference = Forward(Object); Pointer = AddressOf(Reference); } - TReferenceWrapper(const TReferenceWrapper&) = default; + FORCEINLINE constexpr TReferenceWrapper(const TReferenceWrapper&) = default; template requires (CConvertibleTo) - constexpr TReferenceWrapper(const TReferenceWrapper& InValue) + FORCEINLINE constexpr TReferenceWrapper(const TReferenceWrapper& InValue) : Pointer(InValue.Pointer) { } - TReferenceWrapper& operator=(const TReferenceWrapper&) = default; + FORCEINLINE constexpr TReferenceWrapper& operator=(const TReferenceWrapper&) = default; template requires (CConvertibleTo) - constexpr TReferenceWrapper& operator=(const TReferenceWrapper& InValue) + FORCEINLINE constexpr TReferenceWrapper& operator=(const TReferenceWrapper& InValue) { Pointer = InValue.Pointer; return *this; } - constexpr operator ReferencedType&() const { return *Pointer; } - constexpr ReferencedType& Get() const { return *Pointer; } + FORCEINLINE constexpr operator ReferencedType&() const { return *Pointer; } + FORCEINLINE constexpr ReferencedType& Get() const { return *Pointer; } template - constexpr TInvokeResult operator()(Ts&&... Args) const + FORCEINLINE constexpr TInvokeResult operator()(Ts&&... Args) const { return Invoke(Get(), Forward(Args)...); } - constexpr size_t GetTypeHash() const requires (CHashable) + FORCEINLINE constexpr size_t GetTypeHash() const requires (CHashable) { return NAMESPACE_REDCRAFT::GetTypeHash(Get()); } - constexpr void Swap(TReferenceWrapper& InValue) + FORCEINLINE constexpr void Swap(TReferenceWrapper& InValue) { ReferencedType* Temp = Pointer; Pointer = InValue.Pointer; @@ -68,7 +68,7 @@ private: template requires (CObject || CFunction) friend class TReferenceWrapper; // Optimize TOptional with these hacking - constexpr TReferenceWrapper(FInvalid) : Pointer(nullptr) { }; + FORCEINLINE constexpr TReferenceWrapper(FInvalid) : Pointer(nullptr) { }; template requires (CDestructible) friend class TOptional; }; @@ -80,25 +80,25 @@ template void Ref(const T&&) = delete; template -constexpr TReferenceWrapper Ref(T& InValue) +FORCEINLINE constexpr TReferenceWrapper Ref(T& InValue) { return TReferenceWrapper(InValue); } template -constexpr TReferenceWrapper Ref(TReferenceWrapper InValue) +FORCEINLINE constexpr TReferenceWrapper Ref(TReferenceWrapper InValue) { return Ref(InValue.Get()); } template -constexpr TReferenceWrapper Ref(const T& InValue) +FORCEINLINE constexpr TReferenceWrapper Ref(const T& InValue) { return TReferenceWrapper(InValue); } template -constexpr TReferenceWrapper Ref(TReferenceWrapper InValue) +FORCEINLINE constexpr TReferenceWrapper Ref(TReferenceWrapper InValue) { return Ref(InValue.Get()); } @@ -151,87 +151,87 @@ public: using ValueType = OptionalType; - constexpr TOptional() : Reference(Invalid) { } + FORCEINLINE constexpr TOptional() : Reference(Invalid) { } - constexpr TOptional(FInvalid) : TOptional() { } + FORCEINLINE constexpr TOptional(FInvalid) : TOptional() { } template requires (CConstructibleFrom) - constexpr explicit TOptional(FInPlace, Ts&&... Args) + FORCEINLINE constexpr explicit TOptional(FInPlace, Ts&&... Args) : Reference(Forward(Args)...) { } template requires (CConstructibleFrom && !CSameAs, FInPlace> && !CBaseOf>) - constexpr explicit (!CConvertibleTo) TOptional(T&& InValue) + FORCEINLINE constexpr explicit (!CConvertibleTo) TOptional(T&& InValue) : TOptional(InPlace, Forward(InValue)) { } - TOptional(const TOptional& InValue) = default; - TOptional(TOptional&& InValue) = default; + FORCEINLINE TOptional(const TOptional& InValue) = default; + FORCEINLINE TOptional(TOptional&& InValue) = default; template requires (CConstructibleFrom && TAllowUnwrapping::Value) - constexpr explicit (!CConvertibleTo) TOptional(const TOptional& InValue) + FORCEINLINE constexpr explicit (!CConvertibleTo) TOptional(const TOptional& InValue) : Reference(InValue.Reference) { } - ~TOptional() = default; + FORCEINLINE ~TOptional() = default; - TOptional& operator=(const TOptional& InValue) = default; - TOptional& operator=(TOptional&& InValue) = default; + FORCEINLINE TOptional& operator=(const TOptional& InValue) = default; + FORCEINLINE TOptional& operator=(TOptional&& InValue) = default; template requires (CConstructibleFrom && CAssignableFrom && TAllowUnwrapping::Value) - constexpr TOptional& operator=(const TOptional& InValue) + FORCEINLINE constexpr TOptional& operator=(const TOptional& InValue) { Reference = InValue.Reference; return *this; } template requires (CConstructibleFrom && CAssignableFrom) - constexpr TOptional& operator=(T&& InValue) + FORCEINLINE constexpr TOptional& operator=(T&& InValue) { Reference = InValue; return *this; } template requires (CConstructibleFrom) - constexpr OptionalType& Emplace(ArgTypes&&... Args) + FORCEINLINE constexpr OptionalType& Emplace(ArgTypes&&... Args) { Reference = TReferenceWrapper(Forward(Args)...); return Reference; } - constexpr bool IsValid() const { return Reference.Pointer != nullptr; } - constexpr explicit operator bool() const { return Reference.Pointer != nullptr; } + FORCEINLINE constexpr bool IsValid() const { return Reference.Pointer != nullptr; } + FORCEINLINE constexpr explicit operator bool() const { return Reference.Pointer != nullptr; } - constexpr OptionalType& GetValue() & { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return Reference; } - constexpr OptionalType&& GetValue() && { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return Reference; } - constexpr const OptionalType& GetValue() const& { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return Reference; } - constexpr const OptionalType&& GetValue() const&& { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return Reference; } + FORCEINLINE constexpr OptionalType& GetValue() & { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return Reference; } + FORCEINLINE constexpr OptionalType&& GetValue() && { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return Reference; } + FORCEINLINE constexpr const OptionalType& GetValue() const& { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return Reference; } + FORCEINLINE constexpr const OptionalType&& GetValue() const&& { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return Reference; } - constexpr const OptionalType* operator->() const { return &GetValue(); } - constexpr OptionalType* operator->() { return &GetValue(); } + FORCEINLINE constexpr const OptionalType* operator->() const { return &GetValue(); } + FORCEINLINE constexpr OptionalType* operator->() { return &GetValue(); } - constexpr OptionalType& operator*() & { return GetValue(); } - constexpr OptionalType&& operator*() && { return GetValue(); } - constexpr const OptionalType& operator*() const& { return GetValue(); } - constexpr const OptionalType&& operator*() const&& { return GetValue(); } + FORCEINLINE constexpr OptionalType& operator*() & { return GetValue(); } + FORCEINLINE constexpr OptionalType&& operator*() && { return GetValue(); } + FORCEINLINE constexpr const OptionalType& operator*() const& { return GetValue(); } + FORCEINLINE constexpr const OptionalType&& operator*() const&& { return GetValue(); } - constexpr OptionalType& Get( OptionalType& DefaultValue) & { return IsValid() ? GetValue() : DefaultValue; } - constexpr const OptionalType& Get(const OptionalType& DefaultValue) const& { return IsValid() ? GetValue() : DefaultValue; } + FORCEINLINE constexpr OptionalType& Get( OptionalType& DefaultValue) & { return IsValid() ? GetValue() : DefaultValue; } + FORCEINLINE constexpr const OptionalType& Get(const OptionalType& DefaultValue) const& { return IsValid() ? GetValue() : DefaultValue; } - constexpr void Reset() + FORCEINLINE constexpr void Reset() { Reference = Invalid; } - constexpr size_t GetTypeHash() const requires (CHashable) + FORCEINLINE constexpr size_t GetTypeHash() const requires (CHashable) { if (!IsValid()) return 2824517378; return Reference.GetTypeHash(); } - constexpr void Swap(TOptional& InValue) + FORCEINLINE constexpr void Swap(TOptional& InValue) { Reference.Swap(InValue.Reference); } diff --git a/Redcraft.Utility/Source/Public/Templates/Tuple.h b/Redcraft.Utility/Source/Public/Templates/Tuple.h index 47023aa..edb2217 100644 --- a/Redcraft.Utility/Source/Public/Templates/Tuple.h +++ b/Redcraft.Utility/Source/Public/Templates/Tuple.h @@ -82,54 +82,56 @@ private: public: template - constexpr TTupleBasicElement(Type&& Arg) + FORCEINLINE constexpr TTupleBasicElement(Type&& Arg) : Value(Forward(Arg)) { } - TTupleBasicElement() = default; - TTupleBasicElement(TTupleBasicElement&&) = default; - TTupleBasicElement(const TTupleBasicElement&) = default; - TTupleBasicElement& operator=(TTupleBasicElement&&) = default; - TTupleBasicElement& operator=(const TTupleBasicElement&) = default; + FORCEINLINE constexpr TTupleBasicElement() = default; + FORCEINLINE constexpr TTupleBasicElement(const TTupleBasicElement&) = default; + FORCEINLINE constexpr TTupleBasicElement(TTupleBasicElement&&) = default; + FORCEINLINE constexpr TTupleBasicElement& operator=(const TTupleBasicElement&) = default; + FORCEINLINE constexpr TTupleBasicElement& operator=(TTupleBasicElement&&) = default; + FORCEINLINE constexpr ~TTupleBasicElement() = default; - constexpr T& GetValue() & { return static_cast< T& >(Value); } - constexpr const T& GetValue() const & { return static_cast(Value); } - constexpr volatile T& GetValue() volatile& { return static_cast< volatile T& >(Value); } - constexpr const volatile T& GetValue() const volatile& { return static_cast(Value); } - constexpr T&& GetValue() && { return static_cast< T&&>(Value); } - constexpr const T&& GetValue() const && { return static_cast(Value); } - constexpr volatile T&& GetValue() volatile&& { return static_cast< volatile T&&>(Value); } - constexpr const volatile T&& GetValue() const volatile&& { return static_cast(Value); } + FORCEINLINE constexpr T& GetValue() & { return static_cast< T& >(Value); } + FORCEINLINE constexpr const T& GetValue() const & { return static_cast(Value); } + FORCEINLINE constexpr volatile T& GetValue() volatile& { return static_cast< volatile T& >(Value); } + FORCEINLINE constexpr const volatile T& GetValue() const volatile& { return static_cast(Value); } + FORCEINLINE constexpr T&& GetValue() && { return static_cast< T&&>(Value); } + FORCEINLINE constexpr const T&& GetValue() const && { return static_cast(Value); } + FORCEINLINE constexpr volatile T&& GetValue() volatile&& { return static_cast< volatile T&&>(Value); } + FORCEINLINE constexpr const volatile T&& GetValue() const volatile&& { return static_cast(Value); } }; #if RS_TUPLE_ELEMENT_STATIC_ALIAS -#define DEFINE_TTupleBasicElement(Index, Name) \ - template \ - struct TTupleBasicElement \ - { \ - using Name##Type = T; \ - Name##Type Name; \ - \ - template \ - constexpr TTupleBasicElement(Type&& Arg) \ - : Name(Forward(Arg)) \ - { } \ - \ - TTupleBasicElement() = default; \ - TTupleBasicElement(TTupleBasicElement&&) = default; \ - TTupleBasicElement(const TTupleBasicElement&) = default; \ - TTupleBasicElement& operator=(TTupleBasicElement&&) = default; \ - TTupleBasicElement& operator=(const TTupleBasicElement&) = default; \ - \ - constexpr T& GetValue() & { return static_cast< T& >(Name); } \ - constexpr const T& GetValue() const & { return static_cast(Name); } \ - constexpr volatile T& GetValue() volatile& { return static_cast< volatile T& >(Name); } \ - constexpr const volatile T& GetValue() const volatile& { return static_cast(Name); } \ - constexpr T&& GetValue() && { return static_cast< T&&>(Name); } \ - constexpr const T&& GetValue() const && { return static_cast(Name); } \ - constexpr volatile T&& GetValue() volatile&& { return static_cast< volatile T&&>(Name); } \ - constexpr const volatile T&& GetValue() const volatile&& { return static_cast(Name); } \ +#define DEFINE_TTupleBasicElement(Index, Name) \ + template \ + struct TTupleBasicElement \ + { \ + using Name##Type = T; \ + Name##Type Name; \ + \ + template \ + FORCEINLINE constexpr TTupleBasicElement(Type&& Arg) \ + : Name(Forward(Arg)) \ + { } \ + \ + FORCEINLINE constexpr TTupleBasicElement() = default; \ + FORCEINLINE constexpr TTupleBasicElement(const TTupleBasicElement&) = default; \ + FORCEINLINE constexpr TTupleBasicElement(TTupleBasicElement&&) = default; \ + FORCEINLINE constexpr TTupleBasicElement& operator=(const TTupleBasicElement&) = default; \ + FORCEINLINE constexpr TTupleBasicElement& operator=(TTupleBasicElement&&) = default; \ + FORCEINLINE constexpr ~TTupleBasicElement() = default; \ + \ + FORCEINLINE constexpr T& GetValue() & { return static_cast< T& >(Name); } \ + FORCEINLINE constexpr const T& GetValue() const & { return static_cast(Name); } \ + FORCEINLINE constexpr volatile T& GetValue() volatile& { return static_cast< volatile T& >(Name); } \ + FORCEINLINE constexpr const volatile T& GetValue() const volatile& { return static_cast(Name); } \ + FORCEINLINE constexpr T&& GetValue() && { return static_cast< T&&>(Name); } \ + FORCEINLINE constexpr const T&& GetValue() const && { return static_cast(Name); } \ + FORCEINLINE constexpr volatile T&& GetValue() volatile&& { return static_cast< volatile T&&>(Name); } \ + FORCEINLINE constexpr const volatile T&& GetValue() const volatile&& { return static_cast(Name); } \ } DEFINE_TTupleBasicElement(0x0, First); @@ -154,7 +156,7 @@ DEFINE_TTupleBasicElement(0xF, Sixteenth); #endif template -constexpr TTuple...> MakeTupleImpl(Ts&&... Args) +FORCEINLINE constexpr TTuple...> MakeTupleImpl(Ts&&... Args) { return TTuple...>(Forward(Args)...); } @@ -167,24 +169,23 @@ class TTupleImpl, Ts...> : public TTupleBasicElement< { protected: - TTupleImpl() = default; + FORCEINLINE constexpr TTupleImpl() = default; + FORCEINLINE constexpr TTupleImpl(const TTupleImpl&) = default; + FORCEINLINE constexpr TTupleImpl(TTupleImpl&&) = default; + FORCEINLINE constexpr TTupleImpl& operator=(const TTupleImpl&) = default; + FORCEINLINE constexpr TTupleImpl& operator=(TTupleImpl&&) = default; + FORCEINLINE constexpr ~TTupleImpl() = default; template - constexpr explicit TTupleImpl(FForwardingConstructor, ArgTypes&&... Args) + FORCEINLINE constexpr explicit TTupleImpl(FForwardingConstructor, ArgTypes&&... Args) : TTupleBasicElement(Forward(Args))... { } template - constexpr explicit TTupleImpl(FOtherTupleConstructor, TupleType&& InValue) + FORCEINLINE constexpr explicit TTupleImpl(FOtherTupleConstructor, TupleType&& InValue) : TTupleBasicElement(Forward(InValue).template GetValue())... { } - constexpr TTupleImpl(const TTupleImpl&) = default; - constexpr TTupleImpl(TTupleImpl&&) = default; - - constexpr TTupleImpl& operator=(const TTupleImpl&) = default; - constexpr TTupleImpl& operator=(TTupleImpl&&) = default; - }; template @@ -196,7 +197,7 @@ class TTupleHelper> public: template - static constexpr void Assign(LHSTupleType& LHS, RHSTupleType&& RHS) + FORCEINLINE static constexpr void Assign(LHSTupleType& LHS, RHSTupleType&& RHS) { static_assert(sizeof...(Indices) == TTupleArityImpl>::Value && TTupleArityImpl>::Value == TTupleArityImpl>::Value, @@ -206,19 +207,19 @@ public: } template - static constexpr auto Apply(F&& Func, TTupleType&& Arg) + FORCEINLINE static constexpr auto Apply(F&& Func, TTupleType&& Arg) { return Invoke(Forward(Func), Forward(Arg).template GetValue()...); } template - static constexpr auto Transform(F&& Func, TTupleType&& Arg) + FORCEINLINE static constexpr auto Transform(F&& Func, TTupleType&& Arg) { return MakeTupleImpl(Invoke(Forward(Func), Forward(Arg).template GetValue())...); } template - static constexpr T Construct(TTupleType&& Arg) + FORCEINLINE static constexpr T Construct(TTupleType&& Arg) { return T(Forward(Arg).template GetValue()...); } @@ -249,34 +250,34 @@ private: public: - constexpr TTuple() = default; + FORCEINLINE constexpr TTuple() = default; template requires (sizeof...(Ts) >= 1 && sizeof...(ArgTypes) == sizeof...(Ts)) && (true && ... && CConstructibleFrom) - constexpr explicit (!(true && ... && CConvertibleTo)) TTuple(ArgTypes&&... Args) + FORCEINLINE constexpr explicit (!(true && ... && CConvertibleTo)) TTuple(ArgTypes&&... Args) : Super(NAMESPACE_PRIVATE::ForwardingConstructor, Forward(Args)...) { } template requires (sizeof...(OtherTypes) == sizeof...(Ts) && (true && ... && CConstructibleFrom) && NAMESPACE_PRIVATE::TTupleConvertCopy::Value) - constexpr explicit (!(true && ... && CConvertibleTo)) TTuple(const TTuple& InValue) + FORCEINLINE constexpr explicit (!(true && ... && CConvertibleTo)) TTuple(const TTuple& InValue) : Super(NAMESPACE_PRIVATE::OtherTupleConstructor, InValue) { } template requires (sizeof...(OtherTypes) == sizeof...(Ts) && (true && ... && CConstructibleFrom) && NAMESPACE_PRIVATE::TTupleConvertMove::Value) - constexpr explicit (!(true && ... && CConvertibleTo)) TTuple(TTuple&& InValue) + FORCEINLINE constexpr explicit (!(true && ... && CConvertibleTo)) TTuple(TTuple&& InValue) : Super(NAMESPACE_PRIVATE::OtherTupleConstructor, MoveTemp(InValue)) { } - constexpr TTuple(const TTuple&) = default; - constexpr TTuple(TTuple&&) = default; + FORCEINLINE constexpr TTuple(const TTuple&) = default; + FORCEINLINE constexpr TTuple(TTuple&&) = default; template requires (sizeof...(OtherTypes) == sizeof...(Ts) && (true && ... && CAssignableFrom)) - constexpr TTuple& operator=(const TTuple& InValue) + FORCEINLINE constexpr TTuple& operator=(const TTuple& InValue) { Helper::Assign(*this, InValue); return *this; @@ -284,61 +285,61 @@ public: template requires (sizeof...(OtherTypes) == sizeof...(Ts) && (true && ... && CAssignableFrom)) - constexpr TTuple& operator=(TTuple&& InValue) + FORCEINLINE constexpr TTuple& operator=(TTuple&& InValue) { Helper::Assign(*this, MoveTemp(InValue)); return *this; } - constexpr TTuple& operator=(const TTuple&) = default; - constexpr TTuple& operator=(TTuple&&) = default; + FORCEINLINE constexpr TTuple& operator=(const TTuple&) = default; + FORCEINLINE constexpr TTuple& operator=(TTuple&&) = default; - template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() & { return static_cast< NAMESPACE_PRIVATE::TTupleBasicElement>, I>& >(*this).GetValue(); } - template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const & { return static_cast>, I>& >(*this).GetValue(); } - template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() volatile& { return static_cast< volatile NAMESPACE_PRIVATE::TTupleBasicElement>, I>& >(*this).GetValue(); } - template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const volatile& { return static_cast>, I>& >(*this).GetValue(); } - template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() && { return static_cast< NAMESPACE_PRIVATE::TTupleBasicElement>, I>&&>(*this).GetValue(); } - template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const && { return static_cast>, I>&&>(*this).GetValue(); } - template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() volatile&& { return static_cast< volatile NAMESPACE_PRIVATE::TTupleBasicElement>, I>&&>(*this).GetValue(); } - template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const volatile&& { return static_cast>, I>&&>(*this).GetValue(); } + template requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() & { return static_cast< NAMESPACE_PRIVATE::TTupleBasicElement>, I>& >(*this).GetValue(); } + template requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() const & { return static_cast>, I>& >(*this).GetValue(); } + template requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() volatile& { return static_cast< volatile NAMESPACE_PRIVATE::TTupleBasicElement>, I>& >(*this).GetValue(); } + template requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() const volatile& { return static_cast>, I>& >(*this).GetValue(); } + template requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() && { return static_cast< NAMESPACE_PRIVATE::TTupleBasicElement>, I>&&>(*this).GetValue(); } + template requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() const && { return static_cast>, I>&&>(*this).GetValue(); } + template requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() volatile&& { return static_cast< volatile NAMESPACE_PRIVATE::TTupleBasicElement>, I>&&>(*this).GetValue(); } + template requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() const volatile&& { return static_cast>, I>&&>(*this).GetValue(); } - template constexpr decltype(auto) GetValue() & { return static_cast< TTuple& >(*this).GetValue>>(); } - template constexpr decltype(auto) GetValue() const & { return static_cast(*this).GetValue>>(); } - template constexpr decltype(auto) GetValue() volatile& { return static_cast< volatile TTuple& >(*this).GetValue>>(); } - template constexpr decltype(auto) GetValue() const volatile& { return static_cast(*this).GetValue>>(); } - template constexpr decltype(auto) GetValue() && { return static_cast< TTuple&&>(*this).GetValue>>(); } - template constexpr decltype(auto) GetValue() const && { return static_cast(*this).GetValue>>(); } - template constexpr decltype(auto) GetValue() volatile&& { return static_cast< volatile TTuple&&>(*this).GetValue>>(); } - template constexpr decltype(auto) GetValue() const volatile&& { return static_cast(*this).GetValue>>(); } + template FORCEINLINE constexpr decltype(auto) GetValue() & { return static_cast< TTuple& >(*this).GetValue>>(); } + template FORCEINLINE constexpr decltype(auto) GetValue() const & { return static_cast(*this).GetValue>>(); } + template FORCEINLINE constexpr decltype(auto) GetValue() volatile& { return static_cast< volatile TTuple& >(*this).GetValue>>(); } + template FORCEINLINE constexpr decltype(auto) GetValue() const volatile& { return static_cast(*this).GetValue>>(); } + template FORCEINLINE constexpr decltype(auto) GetValue() && { return static_cast< TTuple&&>(*this).GetValue>>(); } + template FORCEINLINE constexpr decltype(auto) GetValue() const && { return static_cast(*this).GetValue>>(); } + template FORCEINLINE constexpr decltype(auto) GetValue() volatile&& { return static_cast< volatile TTuple&&>(*this).GetValue>>(); } + template FORCEINLINE 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) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) & { return Helper::Apply(Forward(Func), static_cast< TTuple& >(*this)); } + template requires (CInvocable) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) const & { return Helper::Apply(Forward(Func), static_cast(*this)); } + template requires (CInvocable) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) volatile& { return Helper::Apply(Forward(Func), static_cast< volatile TTuple& >(*this)); } + template requires (CInvocable) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) const volatile& { return Helper::Apply(Forward(Func), static_cast(*this)); } + template requires (CInvocable) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) && { return Helper::Apply(Forward(Func), static_cast< TTuple&&>(*this)); } + template requires (CInvocable) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) const && { return Helper::Apply(Forward(Func), static_cast(*this)); } + template requires (CInvocable) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) volatile&& { return Helper::Apply(Forward(Func), static_cast< volatile TTuple&&>(*this)); } + template requires (CInvocable) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) const volatile&& { return Helper::Apply(Forward(Func), static_cast(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) & { return Helper::Transform(Forward(Func), static_cast< TTuple& >(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) const & { return Helper::Transform(Forward(Func), static_cast(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) volatile& { return Helper::Transform(Forward(Func), static_cast< volatile TTuple& >(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) const volatile& { return Helper::Transform(Forward(Func), static_cast(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) && { return Helper::Transform(Forward(Func), static_cast< TTuple&&>(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) const && { return Helper::Transform(Forward(Func), static_cast(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) volatile&& { return Helper::Transform(Forward(Func), static_cast< volatile TTuple&&>(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) const volatile&& { return Helper::Transform(Forward(Func), static_cast(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) FORCEINLINE constexpr decltype(auto) Transform(F&& Func) & { return Helper::Transform(Forward(Func), static_cast< TTuple& >(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) FORCEINLINE constexpr decltype(auto) Transform(F&& Func) const & { return Helper::Transform(Forward(Func), static_cast(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) FORCEINLINE constexpr decltype(auto) Transform(F&& Func) volatile& { return Helper::Transform(Forward(Func), static_cast< volatile TTuple& >(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) FORCEINLINE constexpr decltype(auto) Transform(F&& Func) const volatile& { return Helper::Transform(Forward(Func), static_cast(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) FORCEINLINE constexpr decltype(auto) Transform(F&& Func) && { return Helper::Transform(Forward(Func), static_cast< TTuple&&>(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) FORCEINLINE constexpr decltype(auto) Transform(F&& Func) const && { return Helper::Transform(Forward(Func), static_cast(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) FORCEINLINE constexpr decltype(auto) Transform(F&& Func) volatile&& { return Helper::Transform(Forward(Func), static_cast< volatile TTuple&&>(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) FORCEINLINE 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) FORCEINLINE constexpr T Construct() & { return Helper::template Construct(static_cast< TTuple& >(*this)); } + template requires (CConstructibleFrom) FORCEINLINE constexpr T Construct() const & { return Helper::template Construct(static_cast(*this)); } + template requires (CConstructibleFrom) FORCEINLINE constexpr T Construct() volatile& { return Helper::template Construct(static_cast< volatile TTuple& >(*this)); } + template requires (CConstructibleFrom) FORCEINLINE constexpr T Construct() const volatile& { return Helper::template Construct(static_cast(*this)); } + template requires (CConstructibleFrom) FORCEINLINE constexpr T Construct() && { return Helper::template Construct(static_cast< TTuple&&>(*this)); } + template requires (CConstructibleFrom) FORCEINLINE constexpr T Construct() const && { return Helper::template Construct(static_cast(*this)); } + template requires (CConstructibleFrom) FORCEINLINE constexpr T Construct() volatile&& { return Helper::template Construct(static_cast< volatile TTuple&&>(*this)); } + template requires (CConstructibleFrom) FORCEINLINE constexpr T Construct() const volatile&& { return Helper::template Construct(static_cast(*this)); } - constexpr size_t GetTypeHash() const requires (true && ... && CHashable) + FORCEINLINE constexpr size_t GetTypeHash() const requires (true && ... && CHashable) { return [this](TIndexSequence) -> size_t { @@ -347,7 +348,7 @@ public: (TMakeIndexSequence()); } - constexpr void Swap(TTuple& InValue) requires (true && ... && (CMoveConstructible&& CSwappable)) + FORCEINLINE constexpr void Swap(TTuple& InValue) requires (true && ... && (CMoveConstructible && CSwappable)) { [&A = *this, &B = InValue](TIndexSequence) { @@ -365,19 +366,19 @@ template using TPair = TTuple; template -constexpr TTuple...> MakeTuple(Ts&&... Args) +FORCEINLINE constexpr TTuple...> MakeTuple(Ts&&... Args) { return TTuple...>(Forward(Args)...); } template -constexpr TTuple Tie(Ts&... Args) +FORCEINLINE constexpr TTuple Tie(Ts&... Args) { return TTuple(Args...); } template -constexpr TTuple ForwardAsTuple(Ts&&... Args) +FORCEINLINE constexpr TTuple ForwardAsTuple(Ts&&... Args) { return TTuple(Forward(Args)...); } @@ -411,7 +412,7 @@ struct TTupleCatMake, TIndexSequence> struct ForwardType { using Type = TConditional, TRemoveReference&&, U>; }; template - static constexpr TTuple Do(TTupleType&& InValue) + FORCEINLINE static constexpr TTuple Do(TTupleType&& InValue) { return TTuple ( @@ -430,7 +431,7 @@ template struct TTupleCatForward, TIndexSequence> { template - static constexpr decltype(auto) Do(ForwardType&& ForwardTuple, TTupleType&& InValue) + FORCEINLINE static constexpr decltype(auto) Do(ForwardType&& ForwardTuple, TTupleType&& InValue) { return ForwardAsTuple(Forward(ForwardTuple).template GetValue()..., Forward(InValue).template GetValue()...); } @@ -440,7 +441,7 @@ template struct TTupleCatImpl { template - static constexpr decltype(auto) Do(ForwardType&& ForwardTuple, TTupleType&& InValue, OtherTTupleTypes&&... OtherValue) + FORCEINLINE static constexpr decltype(auto) Do(ForwardType&& ForwardTuple, TTupleType&& InValue, OtherTTupleTypes&&... OtherValue) { return Do(TTupleCatForward< TMakeIndexSequence>>, @@ -449,7 +450,7 @@ struct TTupleCatImpl } template - static constexpr decltype(auto) Do(ForwardType&& ForwardTuple) + FORCEINLINE static constexpr decltype(auto) Do(ForwardType&& ForwardTuple) { return TTupleCatMake>>::Do(Forward(ForwardTuple)); } @@ -462,7 +463,7 @@ template struct TTupleThreeWay> { template - static constexpr R Do(const LHSTupleType& LHS, const RHSTupleType& RHS) + FORCEINLINE static constexpr R Do(const LHSTupleType& LHS, const RHSTupleType& RHS) { auto Result = SynthThreeWayCompare(LHS.template GetValue(), RHS.template GetValue()); if (Result != 0) return Result; @@ -474,7 +475,7 @@ template struct TTupleThreeWay> { template - static constexpr R Do(const LHSTupleType& LHS, const RHSTupleType& RHS) + FORCEINLINE static constexpr R Do(const LHSTupleType& LHS, const RHSTupleType& RHS) { return R::equivalent; } @@ -487,7 +488,7 @@ template struct TTupleVisitImpl> { template - static constexpr void Do(F&& Func, TupleTypes&&... Tuples) + FORCEINLINE static constexpr void Do(F&& Func, TupleTypes&&... Tuples) { Invoke(Forward(Func), Forward(Tuples).template GetValue()...); TTupleVisitImpl>::Do(Forward(Func), Forward(Tuples)...); @@ -498,7 +499,7 @@ template <> struct TTupleVisitImpl> { template - static constexpr void Do(TupleTypes&&... Tuples) { } + FORCEINLINE static constexpr void Do(TupleTypes&&... Tuples) { } }; NAMESPACE_PRIVATE_END @@ -507,7 +508,7 @@ template requires (true && ... && CTTuple..., NAMESPACE_PRIVATE::FTupleEndFlag>::Type;; template requires (true && ... && CTTuple>) -constexpr decltype(auto) TupleCat(TTupleTypes&&... Args) +FORCEINLINE constexpr decltype(auto) TupleCat(TTupleTypes&&... Args) { using R = TTupleCatResult; if constexpr (sizeof...(Args) == 0) return R(); @@ -515,14 +516,14 @@ constexpr decltype(auto) TupleCat(TTupleTypes&&... Args) } template requires (sizeof...(LHSTypes) != sizeof...(RHSTypes) || (true && ... && CWeaklyEqualityComparable)) -constexpr bool operator==(const TTuple& LHS, const TTuple& RHS) +FORCEINLINE 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))) -constexpr TCommonComparisonCategory...> operator<=>(const TTuple& LHS, const TTuple& RHS) +FORCEINLINE constexpr TCommonComparisonCategory...> operator<=>(const TTuple& LHS, const TTuple& RHS) { using R = TCommonComparisonCategory...>; return NAMESPACE_PRIVATE::TTupleThreeWay>::Do(LHS, RHS); @@ -530,7 +531,7 @@ constexpr TCommonComparisonCategory...> template requires (CTTuple> && (true && ... && CTTuple>)) -constexpr void VisitTuple(F&& Func, FirstTupleType&& FirstTuple, TupleTypes&&... Tuples) +FORCEINLINE constexpr void VisitTuple(F&& Func, FirstTupleType&& FirstTuple, TupleTypes&&... Tuples) { NAMESPACE_PRIVATE::TTupleVisitImpl>>> ::Do(Forward(Func), Forward(FirstTuple), Forward(Tuples)...); @@ -566,14 +567,14 @@ NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) // Support structure binding, should not be directly used -template constexpr decltype(auto) get( TTuple& InValue) { return static_cast< TTuple& >(InValue).template GetValue(); } -template constexpr decltype(auto) get(const TTuple& InValue) { return static_cast& >(InValue).template GetValue(); } -template constexpr decltype(auto) get( volatile TTuple& InValue) { return static_cast< volatile TTuple& >(InValue).template GetValue(); } -template constexpr decltype(auto) get(const volatile TTuple& InValue) { return static_cast& >(InValue).template GetValue(); } -template constexpr decltype(auto) get( TTuple&& InValue) { return static_cast< TTuple&&>(InValue).template GetValue(); } -template constexpr decltype(auto) get(const TTuple&& InValue) { return static_cast&&>(InValue).template GetValue(); } -template constexpr decltype(auto) get( volatile TTuple&& InValue) { return static_cast< volatile TTuple&&>(InValue).template GetValue(); } -template constexpr decltype(auto) get(const volatile TTuple&& InValue) { return static_cast&&>(InValue).template GetValue(); } +template FORCEINLINE constexpr decltype(auto) get( TTuple& InValue) { return static_cast< TTuple& >(InValue).template GetValue(); } +template FORCEINLINE constexpr decltype(auto) get(const TTuple& InValue) { return static_cast& >(InValue).template GetValue(); } +template FORCEINLINE constexpr decltype(auto) get( volatile TTuple& InValue) { return static_cast< volatile TTuple& >(InValue).template GetValue(); } +template FORCEINLINE constexpr decltype(auto) get(const volatile TTuple& InValue) { return static_cast& >(InValue).template GetValue(); } +template FORCEINLINE constexpr decltype(auto) get( TTuple&& InValue) { return static_cast< TTuple&&>(InValue).template GetValue(); } +template FORCEINLINE constexpr decltype(auto) get(const TTuple&& InValue) { return static_cast&&>(InValue).template GetValue(); } +template FORCEINLINE constexpr decltype(auto) get( volatile TTuple&& InValue) { return static_cast< volatile TTuple&&>(InValue).template GetValue(); } +template FORCEINLINE constexpr decltype(auto) get(const volatile TTuple&& InValue) { return static_cast&&>(InValue).template GetValue(); } NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) diff --git a/Redcraft.Utility/Source/Public/Templates/TypeHash.h b/Redcraft.Utility/Source/Public/Templates/TypeHash.h index 10bea77..0f1b8b6 100644 --- a/Redcraft.Utility/Source/Public/Templates/TypeHash.h +++ b/Redcraft.Utility/Source/Public/Templates/TypeHash.h @@ -9,17 +9,17 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -constexpr size_t HashCombine() +FORCEINLINE constexpr size_t HashCombine() { return 0; } -constexpr size_t HashCombine(size_t A) +FORCEINLINE constexpr size_t HashCombine(size_t A) { return A; } -constexpr size_t HashCombine(size_t A, size_t C) +FORCEINLINE constexpr size_t HashCombine(size_t A, size_t C) { size_t B = static_cast(0x9E3779B97F4A7C16); @@ -40,14 +40,14 @@ constexpr size_t HashCombine(size_t A, size_t C) } template requires (true && ... && CConvertibleTo) -constexpr size_t HashCombine(size_t A, size_t C, Ts... InOther) +FORCEINLINE constexpr size_t HashCombine(size_t A, size_t C, Ts... InOther) { size_t B = HashCombine(A, C); return HashCombine(B, InOther...); } template -constexpr size_t GetTypeHash(T A) +FORCEINLINE 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) } template -constexpr size_t GetTypeHash(T A) +FORCEINLINE constexpr size_t GetTypeHash(T A) { static_assert(sizeof(T) <= 16, "GetTypeHash only works with T up to 128 bits."); @@ -75,25 +75,25 @@ constexpr size_t GetTypeHash(T A) } template -constexpr size_t GetTypeHash(T A) +FORCEINLINE constexpr size_t GetTypeHash(T A) { return GetTypeHash(static_cast>(A)); } template requires (CPointer || CSameAs) -constexpr size_t GetTypeHash(T A) +FORCEINLINE constexpr size_t GetTypeHash(T A) { return GetTypeHash(reinterpret_cast(A)); } template requires (requires(const T& A) { { GetTypeHash(A.GetTypeHash()) } -> CSameAs; }) -constexpr size_t GetTypeHash(const T& A) +FORCEINLINE constexpr size_t GetTypeHash(const T& A) { return GetTypeHash(A.GetTypeHash()); } template requires (requires(const T& A) { { GetTypeHash(A.hash_code()) } -> CSameAs; }) -constexpr size_t GetTypeHash(const T& A) +FORCEINLINE 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 2cabd3e..1f6814d 100644 --- a/Redcraft.Utility/Source/Public/Templates/Utility.h +++ b/Redcraft.Utility/Source/Public/Templates/Utility.h @@ -10,7 +10,7 @@ NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) template -constexpr const T& AsConst(T& Ref) +FORCEINLINE constexpr const T& AsConst(T& Ref) { return Ref; } @@ -19,45 +19,45 @@ template void AsConst(const T&& Ref) = delete; template -constexpr TRemoveReference&& MoveTemp(T&& Obj) +FORCEINLINE constexpr TRemoveReference&& MoveTemp(T&& Obj) { using CastType = TRemoveReference; return static_cast(Obj); } template -constexpr T CopyTemp(T& Obj) +FORCEINLINE constexpr T CopyTemp(T& Obj) { return const_cast(Obj); } template -constexpr T CopyTemp(const T& Obj) +FORCEINLINE constexpr T CopyTemp(const T& Obj) { return Obj; } template -constexpr T&& CopyTemp(T&& Obj) +FORCEINLINE constexpr T&& CopyTemp(T&& Obj) { return MoveTemp(Obj); } template -constexpr T&& Forward(TRemoveReference& Obj) +FORCEINLINE constexpr T&& Forward(TRemoveReference& Obj) { return static_cast(Obj); } template -constexpr T&& Forward(TRemoveReference&& Obj) +FORCEINLINE constexpr T&& Forward(TRemoveReference&& Obj) { return static_cast(Obj); } template requires (requires(T& A, T& B) { A.Swap(B); } || (CMoveConstructible && CMoveAssignable)) -constexpr void Swap(T& A, T& B) +FORCEINLINE constexpr void Swap(T& A, T& B) { if constexpr (requires(T& A, T& B) { A.Swap(B); }) { @@ -72,7 +72,7 @@ constexpr void Swap(T& A, T& B) } template requires (CMoveConstructible && CAssignableFrom) -constexpr T Exchange(T& A, U&& B) +FORCEINLINE constexpr T Exchange(T& A, U&& B) { T Temp = MoveTemp(A); A = Forward(B); @@ -80,16 +80,16 @@ constexpr T Exchange(T& A, U&& B) } template -constexpr TAddRValueReference DeclVal(); +TAddRValueReference DeclVal(); template requires (CObject) -constexpr T* AddressOf(T& Object) +FORCEINLINE constexpr T* AddressOf(T& Object) { return reinterpret_cast(&const_cast(reinterpret_cast(Object))); } template requires (!CObject) -constexpr T* AddressOf(T& Object) +FORCEINLINE constexpr T* AddressOf(T& Object) { return &Object; } @@ -97,7 +97,7 @@ constexpr T* AddressOf(T& Object) struct FIgnore { template - constexpr void operator=(T&&) const { } + FORCEINLINE constexpr void operator=(T&&) const { } }; inline constexpr FIgnore Ignore; diff --git a/Redcraft.Utility/Source/Public/Templates/Variant.h b/Redcraft.Utility/Source/Public/Templates/Variant.h index 6d96ff5..ea05476 100644 --- a/Redcraft.Utility/Source/Public/Templates/Variant.h +++ b/Redcraft.Utility/Source/Public/Templates/Variant.h @@ -84,21 +84,21 @@ class TVariant { public: - constexpr TVariant() : TypeIndex(0xFF) { }; + FORCEINLINE constexpr TVariant() : TypeIndex(0xFF) { }; - constexpr TVariant(FInvalid) : TVariant() { }; + FORCEINLINE constexpr TVariant(FInvalid) : TVariant() { }; - constexpr TVariant(const TVariant& InValue) requires (true && ... && CTriviallyCopyConstructible) = default; + FORCEINLINE constexpr TVariant(const TVariant& InValue) requires (true && ... && CTriviallyCopyConstructible) = default; - constexpr TVariant(const TVariant& InValue) requires ((true && ... && CCopyConstructible) && !(true && ... && CTriviallyCopyConstructible)) + FORCEINLINE constexpr TVariant(const TVariant& InValue) requires ((true && ... && CCopyConstructible) && !(true && ... && CTriviallyCopyConstructible)) : TypeIndex(static_cast(InValue.GetIndex())) { if (IsValid()) CopyConstructImpl[InValue.GetIndex()](&Value, &InValue.Value); } - constexpr TVariant(TVariant&& InValue) requires (true && ... && CTriviallyMoveConstructible) = default; + FORCEINLINE constexpr TVariant(TVariant&& InValue) requires (true && ... && CTriviallyMoveConstructible) = default; - constexpr TVariant(TVariant&& InValue) requires ((true && ... && CMoveConstructible) && !(true && ... && CTriviallyMoveConstructible)) + FORCEINLINE constexpr TVariant(TVariant&& InValue) requires ((true && ... && CMoveConstructible) && !(true && ... && CTriviallyMoveConstructible)) : TypeIndex(static_cast(InValue.GetIndex())) { if (IsValid()) MoveConstructImpl[InValue.GetIndex()](&Value, &InValue.Value); @@ -106,7 +106,7 @@ public: template requires (I < sizeof...(Ts) && CConstructibleFrom>, ArgTypes...>) - constexpr explicit TVariant(TInPlaceIndex, ArgTypes&&... Args) + FORCEINLINE constexpr explicit TVariant(TInPlaceIndex, ArgTypes&&... Args) : TypeIndex(I) { using SelectedType = TVariantAlternative>; @@ -114,26 +114,26 @@ public: } template requires (CConstructibleFrom) - constexpr explicit TVariant(TInPlaceType, ArgTypes&&... Args) + FORCEINLINE constexpr explicit TVariant(TInPlaceType, ArgTypes&&... Args) : TVariant(InPlaceIndex>>, Forward(Args)...) { } template requires (requires { typename NAMESPACE_PRIVATE::TVariantSelectedType; } && !CTInPlaceType> && !CTInPlaceIndex> && !CBaseOf>) - constexpr TVariant(T&& InValue) : TVariant(InPlaceType>, Forward(InValue)) + FORCEINLINE constexpr TVariant(T&& InValue) : TVariant(InPlaceType>, Forward(InValue)) { } - constexpr ~TVariant() requires (true && ... && CTriviallyDestructible) = default; + FORCEINLINE constexpr ~TVariant() requires (true && ... && CTriviallyDestructible) = default; - constexpr ~TVariant() requires (!(true && ... && CTriviallyDestructible)) + FORCEINLINE constexpr ~TVariant() requires (!(true && ... && CTriviallyDestructible)) { Reset(); } - constexpr TVariant& operator=(const TVariant& InValue) requires (true && ... && (CTriviallyCopyConstructible && CTriviallyCopyAssignable)) = default; + FORCEINLINE constexpr TVariant& operator=(const TVariant& InValue) requires (true && ... && (CTriviallyCopyConstructible && CTriviallyCopyAssignable)) = default; - constexpr TVariant& operator=(const TVariant& InValue) requires ((true && ... && (CCopyConstructible && CCopyAssignable)) + FORCEINLINE constexpr TVariant& operator=(const TVariant& InValue) requires ((true && ... && (CCopyConstructible && CCopyAssignable)) && !(true && ... && (CTriviallyCopyConstructible && CTriviallyCopyAssignable))) { if (&InValue == this) return *this; @@ -155,9 +155,9 @@ public: return *this; } - constexpr TVariant& operator=(TVariant&& InValue) requires (true && ... && (CTriviallyMoveConstructible && CTriviallyMoveAssignable)) = default; + FORCEINLINE constexpr TVariant& operator=(TVariant&& InValue) requires (true && ... && (CTriviallyMoveConstructible && CTriviallyMoveAssignable)) = default; - constexpr TVariant& operator=(TVariant&& InValue) requires ((true && ... && (CMoveConstructible && CMoveAssignable)) + FORCEINLINE constexpr TVariant& operator=(TVariant&& InValue) requires ((true && ... && (CMoveConstructible && CMoveAssignable)) && !(true && ... && (CTriviallyMoveConstructible && CTriviallyMoveAssignable))) { if (&InValue == this) return *this; @@ -180,7 +180,7 @@ public: } template requires (requires { typename NAMESPACE_PRIVATE::TVariantSelectedType; }) - constexpr TVariant& operator=(T&& InValue) + FORCEINLINE constexpr TVariant& operator=(T&& InValue) { using SelectedType = NAMESPACE_PRIVATE::TVariantSelectedType; @@ -197,7 +197,7 @@ public: template requires (I < sizeof...(Ts) && CConstructibleFrom>, ArgTypes...>) - constexpr TVariantAlternative>& Emplace(ArgTypes&&... Args) + FORCEINLINE constexpr TVariantAlternative>& Emplace(ArgTypes&&... Args) { Reset(); @@ -209,37 +209,37 @@ public: } template requires (CConstructibleFrom) - constexpr T& Emplace(ArgTypes&&... Args) + FORCEINLINE constexpr T& Emplace(ArgTypes&&... Args) { return Emplace>>(Forward(Args)...); } - constexpr const type_info& GetTypeInfo() const { return IsValid() ? *TypeInfos[GetIndex()] : typeid(void); } + FORCEINLINE constexpr const type_info& GetTypeInfo() const { return IsValid() ? *TypeInfos[GetIndex()] : typeid(void); } - constexpr size_t GetIndex() const { return TypeIndex != 0xFF ? TypeIndex : INDEX_NONE; } - constexpr bool IsValid() const { return TypeIndex != 0xFF; } - constexpr explicit operator bool() const { return TypeIndex != 0xFF; } + FORCEINLINE constexpr size_t GetIndex() const { return TypeIndex != 0xFF ? TypeIndex : INDEX_NONE; } + FORCEINLINE constexpr bool IsValid() const { return TypeIndex != 0xFF; } + FORCEINLINE constexpr explicit operator bool() const { return TypeIndex != 0xFF; } - template constexpr bool HoldsAlternative() const { return IsValid() ? GetIndex() == I : false; } - template constexpr bool HoldsAlternative() const { return IsValid() ? GetIndex() == TVariantIndex> : false; } + template FORCEINLINE constexpr bool HoldsAlternative() const { return IsValid() ? GetIndex() == I : false; } + template FORCEINLINE constexpr bool HoldsAlternative() const { return IsValid() ? GetIndex() == TVariantIndex> : false; } - template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() & { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast< TVariantAlternative>*>(&Value); } - template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() && { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast< TVariantAlternative>*>(&Value)); } - template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const& { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast>*>(&Value); } - template requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const&& { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast>*>(&Value)); } + template requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() & { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast< TVariantAlternative>*>(&Value); } + template requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() && { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast< TVariantAlternative>*>(&Value)); } + template requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() const& { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast>*>(&Value); } + template requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() const&& { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast>*>(&Value)); } - template constexpr decltype(auto) GetValue() & { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast< T*>(&Value); } - template constexpr decltype(auto) GetValue() && { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast< T*>(&Value)); } - template constexpr decltype(auto) GetValue() const& { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast(&Value); } - template constexpr decltype(auto) GetValue() const&& { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast(&Value)); } + template FORCEINLINE constexpr decltype(auto) GetValue() & { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast< T*>(&Value); } + template FORCEINLINE constexpr decltype(auto) GetValue() && { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast< T*>(&Value)); } + template FORCEINLINE constexpr decltype(auto) GetValue() const& { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast(&Value); } + template FORCEINLINE constexpr decltype(auto) GetValue() const&& { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast(&Value)); } - template requires (I < sizeof...(Ts)) constexpr decltype(auto) Get( TVariantAlternative>& DefaultValue) & { return HoldsAlternative() ? GetValue() : DefaultValue; } - template requires (I < sizeof...(Ts)) constexpr decltype(auto) Get(const TVariantAlternative>& DefaultValue) const& { return HoldsAlternative() ? GetValue() : DefaultValue; } + template requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) Get( TVariantAlternative>& DefaultValue) & { return HoldsAlternative() ? GetValue() : DefaultValue; } + template requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) Get(const TVariantAlternative>& DefaultValue) const& { return HoldsAlternative() ? GetValue() : DefaultValue; } - template constexpr decltype(auto) Get( T& DefaultValue) & { return HoldsAlternative() ? GetValue() : DefaultValue; } - template constexpr decltype(auto) Get(const T& DefaultValue) const& { return HoldsAlternative() ? GetValue() : DefaultValue; } + template FORCEINLINE constexpr decltype(auto) Get( T& DefaultValue) & { return HoldsAlternative() ? GetValue() : DefaultValue; } + template FORCEINLINE constexpr decltype(auto) Get(const T& DefaultValue) const& { return HoldsAlternative() ? GetValue() : DefaultValue; } - constexpr void Reset() + FORCEINLINE constexpr void Reset() { if (GetIndex() == INDEX_NONE) return; @@ -251,7 +251,7 @@ public: TypeIndex = static_cast(INDEX_NONE); } - constexpr size_t GetTypeHash() const requires (true && ... && CHashable) + FORCEINLINE constexpr size_t GetTypeHash() const requires (true && ... && CHashable) { if (!IsValid()) return 114514; @@ -263,7 +263,7 @@ public: return HashCombine(GetTypeHash(GetIndex()), HashImpl[GetIndex()](&Value)); } - constexpr void Swap(TVariant& InValue) requires (true && ... && (CMoveConstructible && CSwappable)) + FORCEINLINE constexpr void Swap(TVariant& InValue) requires (true && ... && (CMoveConstructible && CSwappable)) { if (!IsValid() && !InValue.IsValid()) return; @@ -317,7 +317,7 @@ private: TAlignedUnion<1, Ts...> Value; uint8 TypeIndex; - friend constexpr bool operator==(const TVariant& LHS, const TVariant& RHS) requires (true && ... && CEqualityComparable) + friend FORCEINLINE constexpr bool operator==(const TVariant& LHS, const TVariant& RHS) requires (true && ... && CEqualityComparable) { if (LHS.GetIndex() != RHS.GetIndex()) return false; if (LHS.IsValid() == false) return true; @@ -328,7 +328,7 @@ private: return CompareImpl[LHS.GetIndex()](&LHS.Value, &RHS.Value); } - friend constexpr partial_ordering operator<=>(const TVariant& LHS, const TVariant& RHS) requires (true && ... && CSynthThreeWayComparable) + friend FORCEINLINE constexpr partial_ordering operator<=>(const TVariant& LHS, const TVariant& RHS) requires (true && ... && CSynthThreeWayComparable) { if (LHS.GetIndex() != RHS.GetIndex()) return partial_ordering::unordered; if (LHS.IsValid() == false) return partial_ordering::equivalent; @@ -342,13 +342,13 @@ private: }; template requires (!CBaseOf, T> && CEqualityComparable) -constexpr bool operator==(const TVariant& LHS, const T& RHS) +FORCEINLINE constexpr bool operator==(const TVariant& LHS, const T& RHS) { return LHS.template HoldsAlternative() ? LHS.template GetValue() == RHS : false; } template -constexpr bool operator==(const TVariant& LHS, FInvalid) +FORCEINLINE constexpr bool operator==(const TVariant& LHS, FInvalid) { return !LHS.IsValid(); } @@ -360,7 +360,7 @@ struct TVariantVisitImpl { struct GetTotalNum { - static constexpr size_t Do() + FORCEINLINE static constexpr size_t Do() { if (sizeof...(VariantTypes) == 0) return 0; @@ -379,7 +379,7 @@ struct TVariantVisitImpl struct EncodeIndices { - static constexpr size_t Do(initializer_list Indices) + FORCEINLINE static constexpr size_t Do(initializer_list Indices) { constexpr size_t VariantNums[] = { TVariantNum>... }; @@ -397,7 +397,7 @@ struct TVariantVisitImpl struct DecodeExtent { - static constexpr size_t Do(size_t EncodedIndex, size_t Extent) + FORCEINLINE static constexpr size_t Do(size_t EncodedIndex, size_t Extent) { constexpr size_t VariantNums[] = { TVariantNum>... }; @@ -416,7 +416,7 @@ struct TVariantVisitImpl template struct InvokeEncoded> { - static constexpr decltype(auto) Do(F&& Func, VariantTypes&&... Variants) + FORCEINLINE static constexpr decltype(auto) Do(F&& Func, VariantTypes&&... Variants) { return Invoke(Forward(Func), Forward(Variants).template GetValue()...); } @@ -424,7 +424,7 @@ struct TVariantVisitImpl template struct Result { - static constexpr Ret Do(F&& Func, VariantTypes&&... Variants) + FORCEINLINE static constexpr Ret Do(F&& Func, VariantTypes&&... Variants) { return InvokeResult(Forward(Func), Forward(Variants).template GetValue()...); } @@ -437,7 +437,7 @@ struct TVariantVisitImpl template struct InvokeVariant> { - static constexpr decltype(auto) Do(F&& Func, VariantTypes&&... Variants) + FORCEINLINE static constexpr decltype(auto) Do(F&& Func, VariantTypes&&... Variants) { using ExtentIndices = TIndexSequenceFor; @@ -453,7 +453,7 @@ struct TVariantVisitImpl template struct Result { - static constexpr Ret Do(F&& Func, VariantTypes&&... Variants) + FORCEINLINE static constexpr Ret Do(F&& Func, VariantTypes&&... Variants) { using ExtentIndices = TIndexSequenceFor; @@ -466,7 +466,7 @@ struct TVariantVisitImpl }; }; - static constexpr decltype(auto) Do(F&& Func, VariantTypes&&... Variants) + FORCEINLINE static constexpr decltype(auto) Do(F&& Func, VariantTypes&&... Variants) { return InvokeVariant>::Do(Forward(Func), Forward(Variants)...); } @@ -474,7 +474,7 @@ struct TVariantVisitImpl template struct Result { - static constexpr Ret Do(F&& Func, VariantTypes&&... Variants) + FORCEINLINE static constexpr Ret Do(F&& Func, VariantTypes&&... Variants) { return InvokeVariant>::template Result::Do(Forward(Func), Forward(Variants)...); } @@ -485,7 +485,7 @@ NAMESPACE_PRIVATE_END template requires (CTVariant> && (true && ... && CTVariant>)) -constexpr decltype(auto) Visit(F&& Func, FirstVariantType&& FirstVariant, VariantTypes&&... Variants) +FORCEINLINE constexpr decltype(auto) Visit(F&& Func, FirstVariantType&& FirstVariant, VariantTypes&&... Variants) { checkf((true && ... && Variants.IsValid()), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid().")); return NAMESPACE_PRIVATE::TVariantVisitImpl::Do(Forward(Func), Forward(FirstVariant), Forward(Variants)...); @@ -493,7 +493,7 @@ constexpr decltype(auto) Visit(F&& Func, FirstVariantType&& FirstVariant, Varian template requires (CTVariant> && (true && ... && CTVariant>)) -constexpr Ret Visit(F&& Func, FirstVariantType&& FirstVariant, VariantTypes&&... Variants) +FORCEINLINE constexpr Ret Visit(F&& Func, FirstVariantType&& FirstVariant, VariantTypes&&... Variants) { checkf((true && ... && Variants.IsValid()), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid().")); return NAMESPACE_PRIVATE::TVariantVisitImpl::template Result::Do(Forward(Func), Forward(FirstVariant), Forward(Variants)...); diff --git a/Redcraft.Utility/Source/Public/TypeTraits/HelperClasses.h b/Redcraft.Utility/Source/Public/TypeTraits/HelperClasses.h index 42c94dc..6a1a719 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/HelperClasses.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/HelperClasses.h @@ -12,8 +12,8 @@ struct TConstant using ValueType = InType; using Type = TConstant; static constexpr ValueType Value = InValue; - constexpr operator ValueType() const { return Value; } - constexpr ValueType operator()() const { return Value; } + FORCEINLINE constexpr operator ValueType() const { return Value; } + FORCEINLINE constexpr ValueType operator()() const { return Value; } }; template