refactor(templates): remove unnecessary or harmful FORCEINLINE

This commit is contained in:
_Redstone_c_ 2022-12-16 23:23:05 +08:00
parent b6c76ceadc
commit 6cee8a1185
4 changed files with 26 additions and 26 deletions

View File

@ -36,7 +36,7 @@ public:
FORCEINLINE constexpr FAny(FInvalid) : FAny() { } FORCEINLINE constexpr FAny(FInvalid) : FAny() { }
FORCEINLINE FAny(const FAny& InValue) FAny(const FAny& InValue)
: TypeInfo(InValue.TypeInfo) : TypeInfo(InValue.TypeInfo)
{ {
if (!IsValid()) return; if (!IsValid()) return;
@ -61,7 +61,7 @@ public:
} }
} }
FORCEINLINE FAny(FAny&& InValue) FAny(FAny&& InValue)
: TypeInfo(InValue.TypeInfo) : TypeInfo(InValue.TypeInfo)
{ {
if (!IsValid()) return; if (!IsValid()) return;
@ -102,7 +102,7 @@ public:
Destroy(); Destroy();
} }
FORCEINLINE FAny& operator=(const FAny& InValue) FAny& operator=(const FAny& InValue)
{ {
if (&InValue == this) return *this; if (&InValue == this) return *this;
@ -159,7 +159,7 @@ public:
return *this; return *this;
} }
FORCEINLINE FAny& operator=(FAny&& InValue) FAny& operator=(FAny&& InValue)
{ {
if (&InValue == this) return *this; if (&InValue == this) return *this;
@ -276,7 +276,7 @@ public:
Invalidate(); Invalidate();
} }
FORCEINLINE void Swap(FAny& InValue) void Swap(FAny& InValue)
{ {
if (!IsValid() && !InValue.IsValid()) return; if (!IsValid() && !InValue.IsValid()) return;
@ -472,7 +472,7 @@ private:
} }
template <typename T, typename... Ts> template <typename T, typename... Ts>
FORCEINLINE void EmplaceImpl(Ts&&... Args) void EmplaceImpl(Ts&&... Args)
{ {
using DecayedType = TDecay<T>; using DecayedType = TDecay<T>;
@ -505,7 +505,7 @@ private:
} }
} }
FORCEINLINE void Destroy() void Destroy()
{ {
if (!IsValid()) return; if (!IsValid()) return;

View File

@ -103,7 +103,7 @@ public:
FORCEINLINE constexpr TFunctionStorage() = default; FORCEINLINE constexpr TFunctionStorage() = default;
FORCEINLINE TFunctionStorage(const TFunctionStorage& InValue) requires (!bIsUnique) TFunctionStorage(const TFunctionStorage& InValue) requires (!bIsUnique)
: RTTI(InValue.RTTI) : RTTI(InValue.RTTI)
{ {
if (!IsValid()) return; if (!IsValid()) return;
@ -128,7 +128,7 @@ public:
} }
} }
FORCEINLINE TFunctionStorage(TFunctionStorage&& InValue) TFunctionStorage(TFunctionStorage&& InValue)
: RTTI(InValue.RTTI) : RTTI(InValue.RTTI)
{ {
if (!IsValid()) return; if (!IsValid()) return;
@ -158,7 +158,7 @@ public:
Destroy(); Destroy();
} }
FORCEINLINE TFunctionStorage& operator=(const TFunctionStorage& InValue) requires (!bIsUnique) TFunctionStorage& operator=(const TFunctionStorage& InValue) requires (!bIsUnique)
{ {
if (&InValue == this) return *this; if (&InValue == this) return *this;
@ -195,7 +195,7 @@ public:
return *this; return *this;
} }
FORCEINLINE TFunctionStorage& operator=(TFunctionStorage&& InValue) TFunctionStorage& operator=(TFunctionStorage&& InValue)
{ {
if (&InValue == this) return *this; if (&InValue == this) return *this;
@ -238,7 +238,7 @@ public:
FORCEINLINE constexpr bool IsValid() const { return RTTI != 0; } FORCEINLINE constexpr bool IsValid() const { return RTTI != 0; }
// Use Invalidate() to invalidate the storage or use Emplace<T>() to emplace a new object after destruction. // Use Invalidate() to invalidate the storage or use Emplace<T>() to emplace a new object after destruction.
FORCEINLINE void Destroy() void Destroy()
{ {
if (!IsValid()) return; if (!IsValid()) return;
@ -263,7 +263,7 @@ public:
// Make sure you call this function after you have destroyed the held object using Destroy(). // Make sure you call this function after you have destroyed the held object using Destroy().
template <typename T, typename... Ts> template <typename T, typename... Ts>
FORCEINLINE void Emplace(uintptr InCallable, Ts&&... Args) void Emplace(uintptr InCallable, Ts&&... Args)
{ {
Callable = InCallable; Callable = InCallable;
@ -295,7 +295,7 @@ public:
} }
FORCEINLINE void Swap(TFunctionStorage& InValue) void Swap(TFunctionStorage& InValue)
{ {
if (!IsValid() && !InValue.IsValid()) return; if (!IsValid() && !InValue.IsValid()) return;

View File

@ -96,7 +96,7 @@ public:
FORCEINLINE constexpr TOptional& operator=(const TOptional& InValue) requires (CTriviallyCopyConstructible<OptionalType> && CTriviallyCopyAssignable<OptionalType>) = default; FORCEINLINE constexpr TOptional& operator=(const TOptional& InValue) requires (CTriviallyCopyConstructible<OptionalType> && CTriviallyCopyAssignable<OptionalType>) = default;
FORCEINLINE constexpr TOptional& operator=(const TOptional& InValue) requires (CCopyConstructible<OptionalType> && CCopyAssignable<OptionalType> constexpr TOptional& operator=(const TOptional& InValue) requires (CCopyConstructible<OptionalType> && CCopyAssignable<OptionalType>
&& !CTriviallyCopyConstructible<OptionalType> && !CTriviallyCopyAssignable<OptionalType>) && !CTriviallyCopyConstructible<OptionalType> && !CTriviallyCopyAssignable<OptionalType>)
{ {
if (&InValue == this) return *this; if (&InValue == this) return *this;
@ -119,7 +119,7 @@ public:
FORCEINLINE constexpr TOptional& operator=(TOptional&& InValue) requires (CTriviallyMoveConstructible<OptionalType> && CTriviallyMoveAssignable<OptionalType>) = default; FORCEINLINE constexpr TOptional& operator=(TOptional&& InValue) requires (CTriviallyMoveConstructible<OptionalType> && CTriviallyMoveAssignable<OptionalType>) = default;
FORCEINLINE constexpr TOptional& operator=(TOptional&& InValue) requires (CMoveConstructible<OptionalType> && CMoveAssignable<OptionalType> constexpr TOptional& operator=(TOptional&& InValue) requires (CMoveConstructible<OptionalType> && CMoveAssignable<OptionalType>
&& !CTriviallyMoveConstructible<OptionalType> && !CTriviallyMoveAssignable<OptionalType>) && !CTriviallyMoveConstructible<OptionalType> && !CTriviallyMoveAssignable<OptionalType>)
{ {
if (&InValue == this) return *this; if (&InValue == this) return *this;
@ -142,7 +142,7 @@ public:
template <typename T = OptionalType> requires (CConstructibleFrom<OptionalType, const T&> template <typename T = OptionalType> requires (CConstructibleFrom<OptionalType, const T&>
&& CAssignableFrom<OptionalType&, const T&> && NAMESPACE_PRIVATE::CTOptionalAllowUnwrappable<T, OptionalType>) && CAssignableFrom<OptionalType&, const T&> && NAMESPACE_PRIVATE::CTOptionalAllowUnwrappable<T, OptionalType>)
FORCEINLINE constexpr TOptional& operator=(const TOptional<T>& InValue) constexpr TOptional& operator=(const TOptional<T>& InValue)
{ {
if (!InValue.IsValid()) if (!InValue.IsValid())
{ {
@ -162,7 +162,7 @@ public:
template <typename T = OptionalType> requires (CConstructibleFrom<OptionalType, T&&> template <typename T = OptionalType> requires (CConstructibleFrom<OptionalType, T&&>
&& CAssignableFrom<OptionalType&, T&&> && NAMESPACE_PRIVATE::CTOptionalAllowUnwrappable<T, OptionalType>) && CAssignableFrom<OptionalType&, T&&> && NAMESPACE_PRIVATE::CTOptionalAllowUnwrappable<T, OptionalType>)
FORCEINLINE constexpr TOptional& operator=(TOptional<T>&& InValue) constexpr TOptional& operator=(TOptional<T>&& InValue)
{ {
if (!InValue.IsValid()) if (!InValue.IsValid())
{ {
@ -241,7 +241,7 @@ public:
} }
template <typename T> requires (CMoveConstructible<OptionalType> && CSwappable<OptionalType>) template <typename T> requires (CMoveConstructible<OptionalType> && CSwappable<OptionalType>)
FORCEINLINE constexpr void Swap(TOptional& InValue) constexpr void Swap(TOptional& InValue)
{ {
if (!IsValid() && !InValue.IsValid()) return; if (!IsValid() && !InValue.IsValid()) return;

View File

@ -133,7 +133,7 @@ public:
FORCEINLINE constexpr TVariant& operator=(const TVariant& InValue) requires (true && ... && (CTriviallyCopyConstructible<Ts> && CTriviallyCopyAssignable<Ts>)) = default; FORCEINLINE constexpr TVariant& operator=(const TVariant& InValue) requires (true && ... && (CTriviallyCopyConstructible<Ts> && CTriviallyCopyAssignable<Ts>)) = default;
FORCEINLINE constexpr TVariant& operator=(const TVariant& InValue) requires ((true && ... && (CCopyConstructible<Ts> && CCopyAssignable<Ts>)) constexpr TVariant& operator=(const TVariant& InValue) requires ((true && ... && (CCopyConstructible<Ts> && CCopyAssignable<Ts>))
&& !(true && ... && (CTriviallyCopyConstructible<Ts> && CTriviallyCopyAssignable<Ts>))) && !(true && ... && (CTriviallyCopyConstructible<Ts> && CTriviallyCopyAssignable<Ts>)))
{ {
if (&InValue == this) return *this; if (&InValue == this) return *this;
@ -157,7 +157,7 @@ public:
FORCEINLINE constexpr TVariant& operator=(TVariant&& InValue) requires (true && ... && (CTriviallyMoveConstructible<Ts> && CTriviallyMoveAssignable<Ts>)) = default; FORCEINLINE constexpr TVariant& operator=(TVariant&& InValue) requires (true && ... && (CTriviallyMoveConstructible<Ts> && CTriviallyMoveAssignable<Ts>)) = default;
FORCEINLINE constexpr TVariant& operator=(TVariant&& InValue) requires ((true && ... && (CMoveConstructible<Ts> && CMoveAssignable<Ts>)) constexpr TVariant& operator=(TVariant&& InValue) requires ((true && ... && (CMoveConstructible<Ts> && CMoveAssignable<Ts>))
&& !(true && ... && (CTriviallyMoveConstructible<Ts> && CTriviallyMoveAssignable<Ts>))) && !(true && ... && (CTriviallyMoveConstructible<Ts> && CTriviallyMoveAssignable<Ts>)))
{ {
if (&InValue == this) return *this; if (&InValue == this) return *this;
@ -263,7 +263,7 @@ public:
return HashCombine(GetTypeHash(GetIndex()), HashImpl[GetIndex()](&Value)); return HashCombine(GetTypeHash(GetIndex()), HashImpl[GetIndex()](&Value));
} }
FORCEINLINE constexpr void Swap(TVariant& InValue) requires (true && ... && (CMoveConstructible<Ts> && CSwappable<Ts>)) constexpr void Swap(TVariant& InValue) requires (true && ... && (CMoveConstructible<Ts> && CSwappable<Ts>))
{ {
if (!IsValid() && !InValue.IsValid()) return; if (!IsValid() && !InValue.IsValid()) return;
@ -317,7 +317,7 @@ private:
TAlignedUnion<1, Ts...> Value; TAlignedUnion<1, Ts...> Value;
uint8 TypeIndex; uint8 TypeIndex;
friend FORCEINLINE constexpr bool operator==(const TVariant& LHS, const TVariant& RHS) requires (true && ... && CEqualityComparable<Ts>) friend constexpr bool operator==(const TVariant& LHS, const TVariant& RHS) requires (true && ... && CEqualityComparable<Ts>)
{ {
if (LHS.GetIndex() != RHS.GetIndex()) return false; if (LHS.GetIndex() != RHS.GetIndex()) return false;
if (LHS.IsValid() == false) return true; if (LHS.IsValid() == false) return true;
@ -328,7 +328,7 @@ private:
return CompareImpl[LHS.GetIndex()](&LHS.Value, &RHS.Value); return CompareImpl[LHS.GetIndex()](&LHS.Value, &RHS.Value);
} }
friend FORCEINLINE constexpr partial_ordering operator<=>(const TVariant& LHS, const TVariant& RHS) requires (true && ... && CSynthThreeWayComparable<Ts>) friend constexpr partial_ordering operator<=>(const TVariant& LHS, const TVariant& RHS) requires (true && ... && CSynthThreeWayComparable<Ts>)
{ {
if (LHS.GetIndex() != RHS.GetIndex()) return partial_ordering::unordered; if (LHS.GetIndex() != RHS.GetIndex()) return partial_ordering::unordered;
if (LHS.IsValid() == false) return partial_ordering::equivalent; if (LHS.IsValid() == false) return partial_ordering::equivalent;
@ -485,7 +485,7 @@ NAMESPACE_PRIVATE_END
template <typename F, typename FirstVariantType, typename... VariantTypes> template <typename F, typename FirstVariantType, typename... VariantTypes>
requires (CTVariant<TRemoveReference<FirstVariantType>> && (true && ... && CTVariant<TRemoveReference<VariantTypes>>)) requires (CTVariant<TRemoveReference<FirstVariantType>> && (true && ... && CTVariant<TRemoveReference<VariantTypes>>))
FORCEINLINE constexpr decltype(auto) Visit(F&& Func, FirstVariantType&& FirstVariant, VariantTypes&&... Variants) 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().")); checkf((true && ... && Variants.IsValid()), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid()."));
return NAMESPACE_PRIVATE::TVariantVisitImpl<F, FirstVariantType, VariantTypes...>::Do(Forward<F>(Func), Forward<FirstVariantType>(FirstVariant), Forward<VariantTypes>(Variants)...); return NAMESPACE_PRIVATE::TVariantVisitImpl<F, FirstVariantType, VariantTypes...>::Do(Forward<F>(Func), Forward<FirstVariantType>(FirstVariant), Forward<VariantTypes>(Variants)...);
@ -493,7 +493,7 @@ FORCEINLINE constexpr decltype(auto) Visit(F&& Func, FirstVariantType&& FirstVar
template <typename Ret, typename F, typename FirstVariantType, typename... VariantTypes> template <typename Ret, typename F, typename FirstVariantType, typename... VariantTypes>
requires (CTVariant<TRemoveReference<FirstVariantType>> && (true && ... && CTVariant<TRemoveReference<VariantTypes>>)) requires (CTVariant<TRemoveReference<FirstVariantType>> && (true && ... && CTVariant<TRemoveReference<VariantTypes>>))
FORCEINLINE constexpr Ret Visit(F&& Func, FirstVariantType&& FirstVariant, VariantTypes&&... Variants) 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().")); checkf((true && ... && Variants.IsValid()), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid()."));
return NAMESPACE_PRIVATE::TVariantVisitImpl<F, FirstVariantType, VariantTypes...>::template Result<Ret>::Do(Forward<F>(Func), Forward<FirstVariantType>(FirstVariant), Forward<VariantTypes>(Variants)...); return NAMESPACE_PRIVATE::TVariantVisitImpl<F, FirstVariantType, VariantTypes...>::template Result<Ret>::Do(Forward<F>(Func), Forward<FirstVariantType>(FirstVariant), Forward<VariantTypes>(Variants)...);