From 312cfe40979bbd820cb17344ce61981bd16f1723 Mon Sep 17 00:00:00 2001 From: Redstone1024 <2824517378@qq.com> Date: Mon, 16 Dec 2024 19:34:47 +0800 Subject: [PATCH] refactor(*): make type alias identifiers conform to the style for general type identifiers --- .../Source/Private/Memory/Memory.cpp | 6 +- .../Source/Private/Numeric/Random.cpp | 8 +- .../Private/Testing/ContainersTesting.cpp | 4 + .../Source/Private/Testing/MemoryTesting.cpp | 16 +- .../Private/Testing/TemplatesTesting.cpp | 90 +++--- .../Private/Testing/TypeTraitsTesting.cpp | 18 +- .../Source/Public/Containers/Array.h | 300 ++++++++--------- .../Source/Public/Containers/ArrayView.h | 130 ++++---- .../Source/Public/Containers/Bitset.h | 232 +++++++------- .../Source/Public/Containers/List.h | 148 ++++----- .../Source/Public/Containers/StaticArray.h | 68 ++-- .../Source/Public/Containers/StaticBitset.h | 176 +++++----- .../Public/Iterator/BidirectionalIterator.h | 2 +- .../Public/Iterator/ContiguousIterator.h | 2 +- .../Source/Public/Iterator/CountedIterator.h | 18 +- .../Source/Public/Iterator/ForwardIterator.h | 2 +- .../Source/Public/Iterator/InsertIterator.h | 2 +- .../Source/Public/Iterator/MoveIterator.h | 22 +- .../Public/Iterator/RandomAccessIterator.h | 2 +- .../Source/Public/Iterator/ReverseIterator.h | 16 +- .../Source/Public/Iterator/Utility.h | 28 +- .../Source/Public/Memory/Allocator.h | 52 +-- .../Source/Public/Memory/InOutPointer.h | 6 +- .../Source/Public/Memory/PointerTraits.h | 38 +-- .../Source/Public/Memory/SharedPointer.h | 142 ++++---- .../Source/Public/Memory/UniquePointer.h | 16 +- .../Public/Miscellaneous/AssertionMacros.h | 4 + .../Source/Public/Miscellaneous/Compare.h | 24 +- .../Public/Miscellaneous/ConstantIterator.h | 42 +-- .../Public/Miscellaneous/CoreMiscDefines.h | 4 + .../Source/Public/Miscellaneous/Platform.h | 4 + Redcraft.Utility/Source/Public/Numeric/Math.h | 50 +-- .../Source/Public/Range/Factory.h | 80 ++--- .../Source/Public/Range/FilterView.h | 16 +- .../Source/Public/Range/TransformView.h | 2 +- Redcraft.Utility/Source/Public/Range/View.h | 2 +- Redcraft.Utility/Source/Public/String/Char.h | 222 ++++++------- .../Source/Public/String/Conversion.h.inl | 66 ++-- .../Source/Public/String/String.h | 302 +++++++++--------- .../Source/Public/String/StringView.h | 118 +++---- .../Source/Public/Templates/Any.h | 48 +-- .../Source/Public/Templates/Atomic.h | 216 ++++++------- .../Source/Public/Templates/Function.h | 148 ++++----- .../Source/Public/Templates/Invoke.h | 24 +- .../Source/Public/Templates/Meta.h | 46 +-- .../Source/Public/Templates/Optional.h | 42 +-- .../Source/Public/Templates/PropagateConst.h | 20 +- .../Public/Templates/ReferenceWrapper.h | 12 +- .../Source/Public/Templates/Tuple.h | 106 +++--- .../Source/Public/Templates/Utility.h | 4 +- .../Source/Public/Templates/Variant.h | 116 +++---- .../Source/Public/TypeTraits/Common.h | 118 +++---- .../Source/Public/TypeTraits/CopyQualifiers.h | 44 +-- .../Source/Public/TypeTraits/HelperClasses.h | 12 +- 54 files changed, 1738 insertions(+), 1698 deletions(-) diff --git a/Redcraft.Utility/Source/Private/Memory/Memory.cpp b/Redcraft.Utility/Source/Private/Memory/Memory.cpp index ec9ff63..7179d86 100644 --- a/Redcraft.Utility/Source/Private/Memory/Memory.cpp +++ b/Redcraft.Utility/Source/Private/Memory/Memory.cpp @@ -46,7 +46,7 @@ public: }; -FMemoryLeakChecker MemoryLeakChecker; +FMemoryLeakChecker GMemoryLeakChecker; #endif @@ -80,7 +80,7 @@ void* Malloc(size_t Count, size_t Alignment) check(Result != nullptr); - check_code({ MemoryLeakChecker.AddMemoryAllocationCount(); }); + check_code({ GMemoryLeakChecker.AddMemoryAllocationCount(); }); return Result; } @@ -139,7 +139,7 @@ void Free(void* Ptr) } # endif - check_code({ MemoryLeakChecker.ReleaseMemoryAllocationCount(); }); + check_code({ GMemoryLeakChecker.ReleaseMemoryAllocationCount(); }); } size_t QuantizeSize(size_t Count, size_t Alignment) diff --git a/Redcraft.Utility/Source/Private/Numeric/Random.cpp b/Redcraft.Utility/Source/Private/Numeric/Random.cpp index 1d76103..8ac6567 100644 --- a/Redcraft.Utility/Source/Private/Numeric/Random.cpp +++ b/Redcraft.Utility/Source/Private/Numeric/Random.cpp @@ -10,15 +10,15 @@ NAMESPACE_BEGIN(Math) NAMESPACE_UNNAMED_BEGIN -TAtomic RandState = 586103306; +TAtomic GRandState = 586103306; NAMESPACE_UNNAMED_END uint32 Seed(uint32 InSeed) { - uint32 OldSeed = RandState.Load(EMemoryOrder::Relaxed); + uint32 OldSeed = GRandState.Load(EMemoryOrder::Relaxed); - if (InSeed != 0) RandState.Store(InSeed, EMemoryOrder::Relaxed); + if (InSeed != 0) GRandState.Store(InSeed, EMemoryOrder::Relaxed); return OldSeed; } @@ -27,7 +27,7 @@ uint32 Rand() { uint32 Result; - RandState.FetchFn( + GRandState.FetchFn( [&Result](uint32 Value) { Result = Value; diff --git a/Redcraft.Utility/Source/Private/Testing/ContainersTesting.cpp b/Redcraft.Utility/Source/Private/Testing/ContainersTesting.cpp index 48c43be..5868426 100644 --- a/Redcraft.Utility/Source/Private/Testing/ContainersTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/ContainersTesting.cpp @@ -7,6 +7,8 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) +// ReSharper disable CppInconsistentNaming + NAMESPACE_BEGIN(Testing) void TestContainers() @@ -603,6 +605,8 @@ void TestList() NAMESPACE_END(Testing) +// ReSharper restore CppInconsistentNaming + NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Private/Testing/MemoryTesting.cpp b/Redcraft.Utility/Source/Private/Testing/MemoryTesting.cpp index 0157732..4704754 100644 --- a/Redcraft.Utility/Source/Private/Testing/MemoryTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/MemoryTesting.cpp @@ -255,23 +255,23 @@ void TestPointerTraits() always_check(!TPointerTraits::bIsPointer); always_check(TPointerTraits::bIsPointer); - always_check((CSameAs::PointerType, int64*>)); - always_check((CSameAs::ElementType, int64>)); + always_check((CSameAs::FPointerType, int64*>)); + always_check((CSameAs::FElementType, int64>)); always_check(TPointerTraits::ToAddress(nullptr) == nullptr); always_check(TPointerTraits::bIsPointer); - always_check((CSameAs::PointerType, int64(*)[]>)); - always_check((CSameAs::ElementType, int64>)); + always_check((CSameAs::FPointerType, int64(*)[]>)); + always_check((CSameAs::FElementType, int64>)); always_check(TPointerTraits::ToAddress(nullptr) == nullptr); always_check(TPointerTraits>::bIsPointer); - always_check((CSameAs>::PointerType, TSharedPtr>)); - always_check((CSameAs>::ElementType, int64>)); + always_check((CSameAs>::FPointerType, TSharedPtr>)); + always_check((CSameAs>::FElementType, int64>)); always_check(TPointerTraits>::ToAddress(nullptr) == nullptr); always_check(TPointerTraits>::bIsPointer); - always_check((CSameAs>::PointerType, TSharedPtr>)); - always_check((CSameAs>::ElementType, int64>)); + always_check((CSameAs>::FPointerType, TSharedPtr>)); + always_check((CSameAs>::FElementType, int64>)); always_check(TPointerTraits>::ToAddress(nullptr) == nullptr); } diff --git a/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp index a843591..574111c 100644 --- a/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp @@ -64,9 +64,9 @@ void TestInvoke() void TestReferenceWrapper() { - typedef int32(*FuncType)(int32, int32, int32); - FuncType TempA = [](int32 A, int32 B, int32 C) -> int32 { return A * B * C; }; - TReferenceWrapper TempB(TempA); + typedef int32(*FFuncType)(int32, int32, int32); + FFuncType TempA = [](int32 A, int32 B, int32 C) -> int32 { return A * B * C; }; + TReferenceWrapper TempB(TempA); always_check(TempB(1, 1, 1) == 1); TempB.Get() = &TestFunctionA; always_check(TempA(1, 1, 1) == 3); @@ -330,14 +330,15 @@ void TestVariant() } { - using VariantType = TVariant; - VariantType TempArray[] = { 10, 15ll, 1.5 }; + using FVariantType = TVariant; + FVariantType TempArray[] = { 10, 15ll, 1.5 }; for(auto&& TempA : TempArray) { Visit( [](auto&& A) { + // ReSharper disable once CppInconsistentNaming using T = TRemoveCVRef; if constexpr (CSameAs) always_check(A == 10); else if constexpr (CSameAs) always_check(A == 15ll); @@ -347,11 +348,12 @@ void TestVariant() TempA ); - VariantType TempB = Visit([](auto&& A) -> VariantType { return A + A; }, TempA); + FVariantType TempB = Visit([](auto&& A) -> FVariantType { return A + A; }, TempA); Visit( [](auto&& A, auto&& B) { + // ReSharper disable once CppInconsistentNaming using T = TRemoveCVRef; if constexpr (CSameAs) always_check(A == 10 && B == 20); else if constexpr (CSameAs) always_check(A == 15ll && B == 30ll); @@ -366,6 +368,7 @@ void TestVariant() Visit( [](auto&& A) { + // ReSharper disable once CppInconsistentNaming using T = TRemoveCVRef; if constexpr (CSameAs) always_check(A == 20); else if constexpr (CSameAs) always_check(A == 30ll); @@ -417,6 +420,7 @@ void TestVariant() auto TestQualifiers = [&bIsConst, &bIsLValue, &bIsRValue](auto&& A) -> int32 { + // ReSharper disable once CppInconsistentNaming using T = decltype(A); always_check(A == 10); always_check(CConst> == bIsConst); @@ -429,6 +433,8 @@ void TestVariant() bIsLValue = true; bIsRValue = false; + // ReSharper disable CppInconsistentNaming + TVariant TempLA = 10; auto ReturnLA = Visit(TestQualifiers, TempLA); always_check((CSameAs)); @@ -488,6 +494,8 @@ void TestVariant() const TVariant TempRD = TempLC; auto ReturnRD = Visit(TestQualifiers, MoveTemp(TempRD)); always_check((CSameAs)); + + // ReSharper restore CppInconsistentNaming } { @@ -869,11 +877,11 @@ void TestTuple() // always_check((CSameAs>, double>)); { - using Type = TTuple; - Type Temp; + FType Temp; Temp.First = 0; Temp.Second = 0; @@ -892,20 +900,20 @@ void TestTuple() Temp.Fifteenth = 0; Temp.Sixteenth = 0; - always_check(CDefaultConstructible); - always_check(CTriviallyDefaultConstructible); - always_check(CConstructibleFrom); - always_check(CTriviallyConstructibleFrom); - always_check(CCopyConstructible); - always_check(CTriviallyCopyConstructible); - always_check(CMoveConstructible); - always_check(CTriviallyMoveConstructible); - always_check(CCopyAssignable); - always_check(CTriviallyCopyAssignable); - always_check(CMoveAssignable); - always_check(CTriviallyMoveAssignable); - always_check(CDestructible); - always_check(CTriviallyDestructible); + always_check(CDefaultConstructible); + always_check(CTriviallyDefaultConstructible); + always_check(CConstructibleFrom); + always_check(CTriviallyConstructibleFrom); + always_check(CCopyConstructible); + always_check(CTriviallyCopyConstructible); + always_check(CMoveConstructible); + always_check(CTriviallyMoveConstructible); + always_check(CCopyAssignable); + always_check(CTriviallyCopyAssignable); + always_check(CMoveAssignable); + always_check(CTriviallyMoveAssignable); + always_check(CDestructible); + always_check(CTriviallyDestructible); } { @@ -1084,25 +1092,25 @@ struct FFunctionDebug void Print(int32 In) { Output[Index++] = In; } }; -FFunctionDebug FunctionDebug; +FFunctionDebug GFunctionDebug; struct FPrintAdd { FPrintAdd(int32 InNum) : Num(InNum) { } - void F(int32 I) const { FunctionDebug.Print(Num + I); } + void F(int32 I) const { GFunctionDebug.Print(Num + I); } int32 Num; }; void PrintNum(int32 I) { - FunctionDebug.Print(I); + GFunctionDebug.Print(I); } struct FPrintNum { void operator()(int32 I) const { - FunctionDebug.Print(I); + GFunctionDebug.Print(I); } }; @@ -1310,7 +1318,7 @@ void TestFunction() AddDisplay(314159, 1); TFunction Num = &FPrintAdd::Num; - FunctionDebug.Print(Num(Foo)); + GFunctionDebug.Print(Num(Foo)); TFunction AddDisplay2 = [Foo](int32 A) { Foo.F(A); }; AddDisplay2(2); @@ -1326,21 +1334,21 @@ void TestFunction() return Fac(N); }; - for (int32 I = 5; I < 8; ++I) FunctionDebug.Print(Factorial(I)); + for (int32 I = 5; I < 8; ++I) GFunctionDebug.Print(Factorial(I)); - always_check(FunctionDebug.Index == 12); - always_check(FunctionDebug.Output[0] == -9); - always_check(FunctionDebug.Output[1] == 42); - always_check(FunctionDebug.Output[2] == 31337); - always_check(FunctionDebug.Output[3] == 314160); - always_check(FunctionDebug.Output[4] == 314160); - always_check(FunctionDebug.Output[5] == 314159); - always_check(FunctionDebug.Output[6] == 314161); - always_check(FunctionDebug.Output[7] == 314162); - always_check(FunctionDebug.Output[8] == 18); - always_check(FunctionDebug.Output[9] == 120); - always_check(FunctionDebug.Output[10] == 720); - always_check(FunctionDebug.Output[11] == 5040); + always_check(GFunctionDebug.Index == 12); + always_check(GFunctionDebug.Output[0] == -9); + always_check(GFunctionDebug.Output[1] == 42); + always_check(GFunctionDebug.Output[2] == 31337); + always_check(GFunctionDebug.Output[3] == 314160); + always_check(GFunctionDebug.Output[4] == 314160); + always_check(GFunctionDebug.Output[5] == 314159); + always_check(GFunctionDebug.Output[6] == 314161); + always_check(GFunctionDebug.Output[7] == 314162); + always_check(GFunctionDebug.Output[8] == 18); + always_check(GFunctionDebug.Output[9] == 120); + always_check(GFunctionDebug.Output[10] == 720); + always_check(GFunctionDebug.Output[11] == 5040); } { diff --git a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp index ce2a98f..69c5e36 100644 --- a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp @@ -14,7 +14,7 @@ NAMESPACE_BEGIN(Testing) NAMESPACE_UNNAMED_BEGIN -int32 TestObject; +int32 GTestObject; void TestFunction() { } struct FTestStructA { }; @@ -89,7 +89,7 @@ void TestTypeTraits() always_check(!CLValueReference); always_check(CLValueReference); always_check(!CLValueReference); - + always_check(!CRValueReference); always_check(!CRValueReference); always_check(CRValueReference); @@ -428,9 +428,9 @@ void TestTypeTraits() always_check((CSameAs>)); always_check((CSameAs>)); - + // Invocable.h - + always_check((CInvocable)); always_check((CInvocable)); always_check(!(CInvocable)); @@ -462,7 +462,7 @@ void TestTypeTraits() always_check((CSameAs>)); always_check((CSameAs>)); always_check((CSameAs>)); - + always_check((CCommonType)); always_check((CCommonType)); always_check((CCommonType)); @@ -493,7 +493,7 @@ void TestTypeTraits() always_check((CSameAs>)); always_check((CSameAs>)); always_check((CSameAs>)); - + always_check((CSameAs< int32, TCopyVolatile< int32, int32>>)); always_check((CSameAs< int32, TCopyVolatile>)); always_check((CSameAs< volatile int32, TCopyVolatile>)); @@ -503,7 +503,7 @@ void TestTypeTraits() always_check((CSameAs>)); always_check((CSameAs>)); always_check((CSameAs>)); - + always_check((CSameAs< int32, TCopyCV< int32, int32>>)); always_check((CSameAs>)); always_check((CSameAs>)); @@ -513,7 +513,7 @@ void TestTypeTraits() always_check((CSameAs>)); always_check((CSameAs>)); always_check((CSameAs>)); - + always_check((CSameAs>)); always_check((CSameAs>)); always_check((CSameAs>)); @@ -539,7 +539,7 @@ void TestTypeTraits() always_check((CSameAs>)); always_check((CSameAs>)); always_check((CSameAs>)); - + always_check((CSameAs>)); always_check((CSameAs>)); always_check((CSameAs>)); diff --git a/Redcraft.Utility/Source/Public/Containers/Array.h b/Redcraft.Utility/Source/Public/Containers/Array.h index 69e3b06..24b58d9 100644 --- a/Redcraft.Utility/Source/Public/Containers/Array.h +++ b/Redcraft.Utility/Source/Public/Containers/Array.h @@ -27,41 +27,41 @@ private: public: - using ElementType = T; - using AllocatorType = Allocator; + using FElementType = T; + using FAllocatorType = Allocator; - using Reference = T&; - using ConstReference = const T&; + using FReference = T&; + using FConstReference = const T&; - using Iterator = TIteratorImpl; - using ConstIterator = TIteratorImpl; + using FIterator = TIteratorImpl; + using FConstIterator = TIteratorImpl; - using ReverseIterator = TReverseIterator< Iterator>; - using ConstReverseIterator = TReverseIterator; + using FReverseIterator = TReverseIterator< FIterator>; + using FConstReverseIterator = TReverseIterator; - static_assert(CContiguousIterator< Iterator>); - static_assert(CContiguousIterator); + static_assert(CContiguousIterator< FIterator>); + static_assert(CContiguousIterator); /** Default constructor. Constructs an empty container with a default-constructed allocator. */ FORCEINLINE TArray() : TArray(0) { } /** Constructs the container with 'Count' default instances of T. */ - explicit TArray(size_t Count) requires (CDefaultConstructible) + explicit TArray(size_t Count) requires (CDefaultConstructible) { Impl.ArrayNum = Count; Impl.ArrayMax = Impl->CalculateSlackReserve(Num()); Impl.Pointer = Impl->Allocate(Max()); - Memory::DefaultConstruct(Impl.Pointer, Num()); + Memory::DefaultConstruct(Impl.Pointer, Num()); } /** Constructs the container with 'Count' copies of elements with 'InValue'. */ - TArray(size_t Count, const ElementType& InValue) requires (CCopyConstructible) + TArray(size_t Count, const FElementType& InValue) requires (CCopyConstructible) : TArray(MakeCountedConstantIterator(InValue, Count), DefaultSentinel) { } /** Constructs the container with the contents of the range ['First', 'Last'). */ - template S> requires (CConstructibleFrom> && CMovable) + template S> requires (CConstructibleFrom> && CMovable) TArray(I First, S Last) { if constexpr (CForwardIterator) @@ -76,7 +76,7 @@ public: for (size_t Index = 0; Index != Count; ++Index) { - new (Impl.Pointer + Index) ElementType(*First++); + new (Impl.Pointer + Index) FElementType(*First++); } } else @@ -94,17 +94,17 @@ public: } /** Copy constructor. Constructs the container with the copy of the contents of 'InValue'. */ - TArray(const TArray& InValue) requires (CCopyConstructible) + TArray(const TArray& InValue) requires (CCopyConstructible) { Impl.ArrayNum = InValue.Num(); Impl.ArrayMax = Impl->CalculateSlackReserve(Num()); Impl.Pointer = Impl->Allocate(Max()); - Memory::CopyConstruct(Impl.Pointer, InValue.Impl.Pointer, Num()); + Memory::CopyConstruct(Impl.Pointer, InValue.Impl.Pointer, Num()); } /** Move constructor. After the move, 'InValue' is guaranteed to be empty. */ - TArray(TArray&& InValue) requires (CMoveConstructible) + TArray(TArray&& InValue) requires (CMoveConstructible) { Impl.ArrayNum = InValue.Num(); @@ -122,14 +122,14 @@ public: Impl.ArrayMax = Impl->CalculateSlackReserve(Num()); Impl.Pointer = Impl->Allocate(Max()); - Memory::MoveConstruct(Impl.Pointer, InValue.Impl.Pointer, Num()); + Memory::MoveConstruct(Impl.Pointer, InValue.Impl.Pointer, Num()); } InValue.Reset(); } /** Constructs the container with the contents of the initializer list. */ - FORCEINLINE TArray(initializer_list IL) requires (CCopyConstructible) : TArray(Iteration::Begin(IL), Iteration::End(IL)) { } + FORCEINLINE TArray(initializer_list IL) requires (CCopyConstructible) : TArray(Iteration::Begin(IL), Iteration::End(IL)) { } /** Destructs the array. The destructors of the elements are called and the used storage is deallocated. */ ~TArray() @@ -139,7 +139,7 @@ public: } /** Copy assignment operator. Replaces the contents with a copy of the contents of 'InValue'. */ - TArray& operator=(const TArray& InValue) requires (CCopyable) + TArray& operator=(const TArray& InValue) requires (CCopyable) { if (&InValue == this) UNLIKELY return *this; @@ -157,7 +157,7 @@ public: Impl.ArrayMax = NumToAllocate; Impl.Pointer = Impl->Allocate(Max()); - Memory::CopyConstruct(Impl.Pointer, InValue.Impl.Pointer, Num()); + Memory::CopyConstruct(Impl.Pointer, InValue.Impl.Pointer, Num()); return *this; } @@ -170,7 +170,7 @@ public: else if (InValue.Num() <= Max()) { Memory::CopyAssign(Impl.Pointer, InValue.Impl.Pointer, Num()); - Memory::CopyConstruct(Impl.Pointer + Num(), InValue.Impl.Pointer + Num(), InValue.Num() - Num()); + Memory::CopyConstruct(Impl.Pointer + Num(), InValue.Impl.Pointer + Num(), InValue.Num() - Num()); } else check_no_entry(); @@ -180,7 +180,7 @@ public: } /** Move assignment operator. After the move, 'InValue' is guaranteed to be empty. */ - TArray& operator=(TArray&& InValue) requires (CMovable) + TArray& operator=(TArray&& InValue) requires (CMovable) { if (&InValue == this) UNLIKELY return *this; @@ -214,7 +214,7 @@ public: Impl.ArrayMax = NumToAllocate; Impl.Pointer = Impl->Allocate(Max()); - Memory::MoveConstruct(Impl.Pointer, InValue.Impl.Pointer, Num()); + Memory::MoveConstruct(Impl.Pointer, InValue.Impl.Pointer, Num()); InValue.Reset(); @@ -229,7 +229,7 @@ public: else if (InValue.Num() <= Max()) { Memory::MoveAssign(Impl.Pointer, InValue.Impl.Pointer, Num()); - Memory::MoveConstruct(Impl.Pointer + Num(), InValue.Impl.Pointer + Num(), InValue.Num() - Num()); + Memory::MoveConstruct(Impl.Pointer + Num(), InValue.Impl.Pointer + Num(), InValue.Num() - Num()); } else check_no_entry(); @@ -241,7 +241,7 @@ public: } /** Replaces the contents with those identified by initializer list. */ - TArray& operator=(initializer_list IL) requires (CCopyable) + TArray& operator=(initializer_list IL) requires (CCopyable) { size_t NumToAllocate = GetNum(IL); @@ -257,7 +257,7 @@ public: Impl.ArrayMax = NumToAllocate; Impl.Pointer = Impl->Allocate(Max()); - Memory::CopyConstruct(Impl.Pointer, NAMESPACE_REDCRAFT::GetData(IL), Num()); + Memory::CopyConstruct(Impl.Pointer, NAMESPACE_REDCRAFT::GetData(IL), Num()); return *this; } @@ -270,7 +270,7 @@ public: else if (GetNum(IL) <= Max()) { Memory::CopyAssign(Impl.Pointer, NAMESPACE_REDCRAFT::GetData(IL), Num()); - Memory::CopyConstruct(Impl.Pointer + Num(), NAMESPACE_REDCRAFT::GetData(IL) + Num(), GetNum(IL) - Num()); + Memory::CopyConstruct(Impl.Pointer + Num(), NAMESPACE_REDCRAFT::GetData(IL) + Num(), GetNum(IL) - Num()); } else check_no_entry(); @@ -280,7 +280,7 @@ public: } /** Compares the contents of two arrays. */ - NODISCARD friend bool operator==(const TArray& LHS, const TArray& RHS) requires (CWeaklyEqualityComparable) + NODISCARD friend bool operator==(const TArray& LHS, const TArray& RHS) requires (CWeaklyEqualityComparable) { if (LHS.Num() != RHS.Num()) return false; @@ -293,7 +293,7 @@ public: } /** Compares the contents of 'LHS' and 'RHS' lexicographically. */ - NODISCARD friend auto operator<=>(const TArray& LHS, const TArray& RHS) requires (CSynthThreeWayComparable) + NODISCARD friend auto operator<=>(const TArray& LHS, const TArray& RHS) requires (CSynthThreeWayComparable) { const size_t NumToCompare = LHS.Num() < RHS.Num() ? LHS.Num() : RHS.Num(); @@ -306,7 +306,7 @@ public: } /** Inserts 'InValue' before 'Iter' in the container. */ - Iterator Insert(ConstIterator Iter, const ElementType& InValue) requires (CCopyable) + FIterator Insert(FConstIterator Iter, const FElementType& InValue) requires (CCopyable) { checkf(IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator().")); @@ -318,26 +318,26 @@ public: if (NumToAllocate != Max()) { - ElementType* OldAllocation = Impl.Pointer; - const size_t NumToDestruct = Num(); + FElementType* OldAllocation = Impl.Pointer; + const size_t NumToDestruct = Num(); Impl.ArrayNum = Num() + 1; Impl.ArrayMax = NumToAllocate; Impl.Pointer = Impl->Allocate(Max()); - Memory::MoveConstruct(Impl.Pointer, OldAllocation, InsertIndex); - new (Impl.Pointer + InsertIndex) ElementType(InValue); - Memory::MoveConstruct(Impl.Pointer + InsertIndex + 1, OldAllocation + InsertIndex, NumToDestruct - InsertIndex); + Memory::MoveConstruct(Impl.Pointer, OldAllocation, InsertIndex); + new (Impl.Pointer + InsertIndex) FElementType(InValue); + Memory::MoveConstruct(Impl.Pointer + InsertIndex + 1, OldAllocation + InsertIndex, NumToDestruct - InsertIndex); Memory::Destruct(OldAllocation, NumToDestruct); Impl->Deallocate(OldAllocation); - return Iterator(this, Impl.Pointer + InsertIndex); + return FIterator(this, Impl.Pointer + InsertIndex); } if (InsertIndex != Num()) { - new (Impl.Pointer + Num()) ElementType(MoveTemp(Impl.Pointer[Num() - 1])); + new (Impl.Pointer + Num()) FElementType(MoveTemp(Impl.Pointer[Num() - 1])); for (size_t Index = Num() - 1; Index != InsertIndex; --Index) { @@ -346,15 +346,15 @@ public: Impl.Pointer[InsertIndex] = InValue; } - else new (Impl.Pointer + Num()) ElementType(InValue); + else new (Impl.Pointer + Num()) FElementType(InValue); Impl.ArrayNum = Num() + 1; - return Iterator(this, Impl.Pointer + InsertIndex); + return FIterator(this, Impl.Pointer + InsertIndex); } /** Inserts 'InValue' before 'Iter' in the container. */ - Iterator Insert(ConstIterator Iter, ElementType&& InValue) requires (CMovable) + FIterator Insert(FConstIterator Iter, FElementType&& InValue) requires (CMovable) { checkf(IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator().")); @@ -366,26 +366,26 @@ public: if (NumToAllocate != Max()) { - ElementType* OldAllocation = Impl.Pointer; - const size_t NumToDestruct = Num(); + FElementType* OldAllocation = Impl.Pointer; + const size_t NumToDestruct = Num(); Impl.ArrayNum = Num() + 1; Impl.ArrayMax = NumToAllocate; Impl.Pointer = Impl->Allocate(Max()); - Memory::MoveConstruct(Impl.Pointer, OldAllocation, InsertIndex); - new (Impl.Pointer + InsertIndex) ElementType(MoveTemp(InValue)); - Memory::MoveConstruct(Impl.Pointer + InsertIndex + 1, OldAllocation + InsertIndex, NumToDestruct - InsertIndex); + Memory::MoveConstruct(Impl.Pointer, OldAllocation, InsertIndex); + new (Impl.Pointer + InsertIndex) FElementType(MoveTemp(InValue)); + Memory::MoveConstruct(Impl.Pointer + InsertIndex + 1, OldAllocation + InsertIndex, NumToDestruct - InsertIndex); Memory::Destruct(OldAllocation, NumToDestruct); Impl->Deallocate(OldAllocation); - return Iterator(this, Impl.Pointer + InsertIndex); + return FIterator(this, Impl.Pointer + InsertIndex); } if (InsertIndex != Num()) { - new (Impl.Pointer + Num()) ElementType(MoveTemp(Impl.Pointer[Num() - 1])); + new (Impl.Pointer + Num()) FElementType(MoveTemp(Impl.Pointer[Num() - 1])); for (size_t Index = Num() - 1; Index != InsertIndex; --Index) { @@ -394,15 +394,15 @@ public: Impl.Pointer[InsertIndex] = MoveTemp(InValue); } - else new (Impl.Pointer + Num()) ElementType(MoveTemp(InValue)); + else new (Impl.Pointer + Num()) FElementType(MoveTemp(InValue)); Impl.ArrayNum = Num() + 1; - return Iterator(this, Impl.Pointer + InsertIndex); + return FIterator(this, Impl.Pointer + InsertIndex); } /** Inserts 'Count' copies of the 'InValue' before 'Iter' in the container. */ - Iterator Insert(ConstIterator Iter, size_t Count, const ElementType& InValue) requires (CCopyable) + FIterator Insert(FConstIterator Iter, size_t Count, const FElementType& InValue) requires (CCopyable) { checkf(IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator().")); @@ -410,9 +410,9 @@ public: } /** Inserts elements from range ['First', 'Last') before 'Iter'. */ - template S> requires (CConstructibleFrom> - && CAssignableFrom> && CMovable) - Iterator Insert(ConstIterator Iter, I First, S Last) + template S> requires (CConstructibleFrom> + && CAssignableFrom> && CMovable) + FIterator Insert(FConstIterator Iter, I First, S Last) { checkf(IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator().")); @@ -423,7 +423,7 @@ public: const size_t InsertIndex = Iter - Begin(); const size_t Count = Iteration::Distance(First, Last); - if (Count == 0) return Iterator(this, Impl.Pointer + InsertIndex); + if (Count == 0) return FIterator(this, Impl.Pointer + InsertIndex); const size_t NumToAllocate = Num() + Count > Max() ? Impl->CalculateSlackGrow(Num() + Count, Max()) : Max(); @@ -431,26 +431,26 @@ public: if (NumToAllocate != Max()) { - ElementType* OldAllocation = Impl.Pointer; - const size_t NumToDestruct = Num(); + FElementType* OldAllocation = Impl.Pointer; + const size_t NumToDestruct = Num(); Impl.ArrayNum = Num() + Count; Impl.ArrayMax = NumToAllocate; Impl.Pointer = Impl->Allocate(Max()); - Memory::MoveConstruct(Impl.Pointer, OldAllocation, InsertIndex); + Memory::MoveConstruct(Impl.Pointer, OldAllocation, InsertIndex); for (size_t Index = InsertIndex; Index != InsertIndex + Count; ++Index) { - new (Impl.Pointer + Index) ElementType(*First++); + new (Impl.Pointer + Index) FElementType(*First++); } - Memory::MoveConstruct(Impl.Pointer + InsertIndex + Count, OldAllocation + InsertIndex, NumToDestruct - InsertIndex); + Memory::MoveConstruct(Impl.Pointer + InsertIndex + Count, OldAllocation + InsertIndex, NumToDestruct - InsertIndex); Memory::Destruct(OldAllocation, NumToDestruct); Impl->Deallocate(OldAllocation); - return Iterator(this, Impl.Pointer + InsertIndex); + return FIterator(this, Impl.Pointer + InsertIndex); } /* @@ -492,7 +492,7 @@ public: for (size_t TargetIndex = IndexO - 1; TargetIndex != IndexD - 1; --TargetIndex) { - new (Impl.Pointer + TargetIndex) ElementType(MoveTemp(Impl.Pointer[TargetIndex - Count])); + new (Impl.Pointer + TargetIndex) FElementType(MoveTemp(Impl.Pointer[TargetIndex - Count])); } for (size_t TargetIndex = IndexD - 1; TargetIndex != IndexC - 1; --TargetIndex) @@ -507,14 +507,14 @@ public: for (size_t TargetIndex = IndexB; TargetIndex != IndexC; ++TargetIndex) { - new (Impl.Pointer + TargetIndex) ElementType(*First++); + new (Impl.Pointer + TargetIndex) FElementType(*First++); } check(First == Last); Impl.ArrayNum = Num() + Count; - return Iterator(this, Impl.Pointer + InsertIndex); + return FIterator(this, Impl.Pointer + InsertIndex); } else { @@ -524,14 +524,14 @@ public: } /** Inserts elements from initializer list before 'Iter' in the container. */ - FORCEINLINE Iterator Insert(ConstIterator Iter, initializer_list IL) requires (CCopyable) + FORCEINLINE FIterator Insert(FConstIterator Iter, initializer_list IL) requires (CCopyable) { return Insert(Iter, Iteration::Begin(IL), Iteration::End(IL)); } /** Inserts a new element into the container directly before 'Iter'. */ - template requires (CConstructibleFrom && CMovable) - Iterator Emplace(ConstIterator Iter, Ts&&... Args) + template requires (CConstructibleFrom && CMovable) + FIterator Emplace(FConstIterator Iter, Ts&&... Args) { checkf(IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator().")); @@ -543,43 +543,43 @@ public: if (NumToAllocate != Max()) { - ElementType* OldAllocation = Impl.Pointer; - const size_t NumToDestruct = Num(); + FElementType* OldAllocation = Impl.Pointer; + const size_t NumToDestruct = Num(); Impl.ArrayNum = Num() + 1; Impl.ArrayMax = NumToAllocate; Impl.Pointer = Impl->Allocate(Max()); - Memory::MoveConstruct(Impl.Pointer, OldAllocation, InsertIndex); - new (Impl.Pointer + InsertIndex) ElementType(Forward(Args)...); - Memory::MoveConstruct(Impl.Pointer + InsertIndex + 1, OldAllocation + InsertIndex, NumToDestruct - InsertIndex); + Memory::MoveConstruct(Impl.Pointer, OldAllocation, InsertIndex); + new (Impl.Pointer + InsertIndex) FElementType(Forward(Args)...); + Memory::MoveConstruct(Impl.Pointer + InsertIndex + 1, OldAllocation + InsertIndex, NumToDestruct - InsertIndex); Memory::Destruct(OldAllocation, NumToDestruct); Impl->Deallocate(OldAllocation); - return Iterator(this, Impl.Pointer + InsertIndex); + return FIterator(this, Impl.Pointer + InsertIndex); } if (InsertIndex != Num()) { - new (Impl.Pointer + Num()) ElementType(MoveTemp(Impl.Pointer[Num() - 1])); + new (Impl.Pointer + Num()) FElementType(MoveTemp(Impl.Pointer[Num() - 1])); for (size_t Index = Num() - 1; Index != InsertIndex; --Index) { Impl.Pointer[Index] = MoveTemp(Impl.Pointer[Index - 1]); } - Impl.Pointer[InsertIndex] = ElementType(Forward(Args)...); + Impl.Pointer[InsertIndex] = FElementType(Forward(Args)...); } - else new (Impl.Pointer + Num()) ElementType(Forward(Args)...); + else new (Impl.Pointer + Num()) FElementType(Forward(Args)...); Impl.ArrayNum = Num() + 1; - return Iterator(this, Impl.Pointer + InsertIndex); + return FIterator(this, Impl.Pointer + InsertIndex); } /** Removes the element at 'Iter' in the container. Without changing the order of elements. */ - FORCEINLINE Iterator StableErase(ConstIterator Iter, bool bAllowShrinking = true) requires (CMovable) + FORCEINLINE FIterator StableErase(FConstIterator Iter, bool bAllowShrinking = true) requires (CMovable) { checkf(IsValidIterator(Iter) && Iter != End(), TEXT("Read access violation. Please check IsValidIterator().")); @@ -587,33 +587,33 @@ public: } /** Removes the elements in the range ['First', 'Last') in the container. Without changing the order of elements. */ - Iterator StableErase(ConstIterator First, ConstIterator Last, bool bAllowShrinking = true) requires (CMovable) + FIterator StableErase(FConstIterator First, FConstIterator Last, bool bAllowShrinking = true) requires (CMovable) { checkf(IsValidIterator(First) && IsValidIterator(Last) && First <= Last, TEXT("Read access violation. Please check IsValidIterator().")); const size_t EraseIndex = First - Begin(); const size_t EraseCount = Last - First; - if (EraseCount == 0) return Iterator(this, Impl.Pointer + EraseIndex); + if (EraseCount == 0) return FIterator(this, Impl.Pointer + EraseIndex); const size_t NumToAllocate = bAllowShrinking ? Impl->CalculateSlackShrink(Num() - EraseCount, Max()) : Max(); if (NumToAllocate != Max()) { - ElementType* OldAllocation = Impl.Pointer; - const size_t NumToDestruct = Num(); + FElementType* OldAllocation = Impl.Pointer; + const size_t NumToDestruct = Num(); Impl.ArrayNum = Num() - EraseCount; Impl.ArrayMax = NumToAllocate; Impl.Pointer = Impl->Allocate(Max()); - Memory::MoveConstruct(Impl.Pointer, OldAllocation, EraseIndex); - Memory::MoveConstruct(Impl.Pointer + EraseIndex, OldAllocation + EraseIndex + EraseCount, NumToDestruct - EraseIndex - EraseCount); + Memory::MoveConstruct(Impl.Pointer, OldAllocation, EraseIndex); + Memory::MoveConstruct(Impl.Pointer + EraseIndex, OldAllocation + EraseIndex + EraseCount, NumToDestruct - EraseIndex - EraseCount); Memory::Destruct(OldAllocation, NumToDestruct); Impl->Deallocate(OldAllocation); - return Iterator(this, Impl.Pointer + EraseIndex); + return FIterator(this, Impl.Pointer + EraseIndex); } for (size_t Index = EraseIndex + EraseCount; Index != Num(); ++Index) @@ -625,11 +625,11 @@ public: Impl.ArrayNum = Num() - EraseCount; - return Iterator(this, Impl.Pointer + EraseIndex); + return FIterator(this, Impl.Pointer + EraseIndex); } /** Removes the element at 'Iter' in the container. But it may change the order of elements. */ - FORCEINLINE Iterator Erase(ConstIterator Iter, bool bAllowShrinking = true) requires (CMovable) + FORCEINLINE FIterator Erase(FConstIterator Iter, bool bAllowShrinking = true) requires (CMovable) { checkf(IsValidIterator(Iter) && Iter != End(), TEXT("Read access violation. Please check IsValidIterator().")); @@ -637,33 +637,33 @@ public: } /** Removes the elements in the range ['First', 'Last') in the container. But it may change the order of elements. */ - Iterator Erase(ConstIterator First, ConstIterator Last, bool bAllowShrinking = true) requires (CMovable) + FIterator Erase(FConstIterator First, FConstIterator Last, bool bAllowShrinking = true) requires (CMovable) { checkf(IsValidIterator(First) && IsValidIterator(Last) && First <= Last, TEXT("Read access violation. Please check IsValidIterator().")); const size_t EraseIndex = First - Begin(); const size_t EraseCount = Last - First; - if (EraseCount == 0) return Iterator(this, Impl.Pointer + EraseIndex); + if (EraseCount == 0) return FIterator(this, Impl.Pointer + EraseIndex); const size_t NumToAllocate = bAllowShrinking ? Impl->CalculateSlackShrink(Num() - EraseCount, Max()) : Max(); if (NumToAllocate != Max()) { - ElementType* OldAllocation = Impl.Pointer; - const size_t NumToDestruct = Num(); + FElementType* OldAllocation = Impl.Pointer; + const size_t NumToDestruct = Num(); Impl.ArrayNum = Num() - EraseCount; Impl.ArrayMax = NumToAllocate; Impl.Pointer = Impl->Allocate(Max()); - Memory::MoveConstruct(Impl.Pointer, OldAllocation, EraseIndex); - Memory::MoveConstruct(Impl.Pointer + EraseIndex, OldAllocation + EraseIndex + EraseCount, NumToDestruct - EraseIndex - EraseCount); + Memory::MoveConstruct(Impl.Pointer, OldAllocation, EraseIndex); + Memory::MoveConstruct(Impl.Pointer + EraseIndex, OldAllocation + EraseIndex + EraseCount, NumToDestruct - EraseIndex - EraseCount); Memory::Destruct(OldAllocation, NumToDestruct); Impl->Deallocate(OldAllocation); - return Iterator(this, Impl.Pointer + EraseIndex); + return FIterator(this, Impl.Pointer + EraseIndex); } for (size_t Index = 0; Index != EraseCount; ++Index) @@ -677,24 +677,24 @@ public: Impl.ArrayNum = Num() - EraseCount; - return Iterator(this, Impl.Pointer + EraseIndex); + return FIterator(this, Impl.Pointer + EraseIndex); } /** Appends the given element value to the end of the container. */ - FORCEINLINE void PushBack(const ElementType& InValue) requires (CCopyable) + FORCEINLINE void PushBack(const FElementType& InValue) requires (CCopyable) { EmplaceBack(InValue); } /** Appends the given element value to the end of the container. */ - FORCEINLINE void PushBack(ElementType&& InValue) requires (CMovable) + FORCEINLINE void PushBack(FElementType&& InValue) requires (CMovable) { EmplaceBack(MoveTemp(InValue)); } /** Appends a new element to the end of the container. */ - template requires (CConstructibleFrom && CMovable) - ElementType& EmplaceBack(Ts&&... Args) + template requires (CConstructibleFrom && CMovable) + FElementType& EmplaceBack(Ts&&... Args) { const size_t NumToAllocate = Num() + 1 > Max() ? Impl->CalculateSlackGrow(Num() + 1, Max()) : Max(); @@ -702,15 +702,15 @@ public: if (NumToAllocate != Max()) { - ElementType* OldAllocation = Impl.Pointer; - const size_t NumToDestruct = Num(); + FElementType* OldAllocation = Impl.Pointer; + const size_t NumToDestruct = Num(); Impl.ArrayNum = Num() + 1; Impl.ArrayMax = NumToAllocate; Impl.Pointer = Impl->Allocate(Max()); - Memory::MoveConstruct(Impl.Pointer, OldAllocation, Num() - 1); - new (Impl.Pointer + Num() - 1) ElementType(Forward(Args)...); + Memory::MoveConstruct(Impl.Pointer, OldAllocation, Num() - 1); + new (Impl.Pointer + Num() - 1) FElementType(Forward(Args)...); Memory::Destruct(OldAllocation, NumToDestruct); Impl->Deallocate(OldAllocation); @@ -718,7 +718,7 @@ public: return Impl.Pointer[Num() - 1]; } - new (Impl.Pointer + Num()) ElementType(Forward(Args)...); + new (Impl.Pointer + Num()) FElementType(Forward(Args)...); Impl.ArrayNum = Num() + 1; @@ -726,13 +726,13 @@ public: } /** Removes the last element of the container. The array cannot be empty. */ - FORCEINLINE void PopBack(bool bAllowShrinking = true) requires (CMovable) + FORCEINLINE void PopBack(bool bAllowShrinking = true) requires (CMovable) { Erase(End() - 1, bAllowShrinking); } /** Resizes the container to contain 'Count' elements. Additional default elements are appended. */ - void SetNum(size_t Count, bool bAllowShrinking = true) requires (CDefaultConstructible && CMovable) + void SetNum(size_t Count, bool bAllowShrinking = true) requires (CDefaultConstructible && CMovable) { size_t NumToAllocate = Count; @@ -741,8 +741,8 @@ public: if (NumToAllocate != Max()) { - ElementType* OldAllocation = Impl.Pointer; - const size_t NumToDestruct = Num(); + FElementType* OldAllocation = Impl.Pointer; + const size_t NumToDestruct = Num(); Impl.ArrayNum = Count; Impl.ArrayMax = NumToAllocate; @@ -750,12 +750,12 @@ public: if (NumToDestruct <= Num()) { - Memory::MoveConstruct(Impl.Pointer, OldAllocation, NumToDestruct); - Memory::DefaultConstruct(Impl.Pointer + NumToDestruct, Num() - NumToDestruct); + Memory::MoveConstruct(Impl.Pointer, OldAllocation, NumToDestruct); + Memory::DefaultConstruct(Impl.Pointer + NumToDestruct, Num() - NumToDestruct); } else { - Memory::MoveConstruct(Impl.Pointer, OldAllocation, Num()); + Memory::MoveConstruct(Impl.Pointer, OldAllocation, Num()); } Memory::Destruct(OldAllocation, NumToDestruct); @@ -770,7 +770,7 @@ public: } else if (Count <= Max()) { - Memory::DefaultConstruct(Impl.Pointer + Num(), Count - Num()); + Memory::DefaultConstruct(Impl.Pointer + Num(), Count - Num()); } else check_no_entry(); @@ -778,7 +778,7 @@ public: } /** Resizes the container to contain 'Count' elements. Additional copies of 'InValue' are appended. */ - void SetNum(size_t Count, const ElementType& InValue, bool bAllowShrinking = true) requires (CCopyConstructible && CMovable) + void SetNum(size_t Count, const FElementType& InValue, bool bAllowShrinking = true) requires (CCopyConstructible && CMovable) { size_t NumToAllocate = Count; @@ -787,8 +787,8 @@ public: if (NumToAllocate != Max()) { - ElementType* OldAllocation = Impl.Pointer; - const size_t NumToDestruct = Num(); + FElementType* OldAllocation = Impl.Pointer; + const size_t NumToDestruct = Num(); Impl.ArrayNum = Count; Impl.ArrayMax = NumToAllocate; @@ -796,16 +796,16 @@ public: if (NumToDestruct <= Num()) { - Memory::MoveConstruct(Impl.Pointer, OldAllocation, NumToDestruct); + Memory::MoveConstruct(Impl.Pointer, OldAllocation, NumToDestruct); for (size_t Index = NumToDestruct; Index != Num(); ++Index) { - new (Impl.Pointer + Index) ElementType(InValue); + new (Impl.Pointer + Index) FElementType(InValue); } } else { - Memory::MoveConstruct(Impl.Pointer, OldAllocation, Num()); + Memory::MoveConstruct(Impl.Pointer, OldAllocation, Num()); } Memory::Destruct(OldAllocation, NumToDestruct); @@ -822,7 +822,7 @@ public: { for (size_t Index = Num(); Index != Count; ++Index) { - new (Impl.Pointer + Index) ElementType(InValue); + new (Impl.Pointer + Index) FElementType(InValue); } } else check_no_entry(); @@ -831,19 +831,19 @@ public: } /** Increase the max capacity of the array to a value that's greater or equal to 'Count'. */ - void Reserve(size_t Count) requires (CMovable) + void Reserve(size_t Count) requires (CMovable) { if (Count <= Max()) return; - const size_t NumToAllocate = Impl->CalculateSlackReserve(Count); - ElementType* OldAllocation = Impl.Pointer; + const size_t NumToAllocate = Impl->CalculateSlackReserve(Count); + FElementType* OldAllocation = Impl.Pointer; check(NumToAllocate > Max()); Impl.ArrayMax = NumToAllocate; Impl.Pointer = Impl->Allocate(Max()); - Memory::MoveConstruct(Impl.Pointer, OldAllocation, Num()); + Memory::MoveConstruct(Impl.Pointer, OldAllocation, Num()); Memory::Destruct(OldAllocation, Num()); Impl->Deallocate(OldAllocation); @@ -858,32 +858,32 @@ public: if (NumToAllocate == Max()) return; - ElementType* OldAllocation = Impl.Pointer; + FElementType* OldAllocation = Impl.Pointer; Impl.ArrayMax = NumToAllocate; Impl.Pointer = Impl->Allocate(Max()); - Memory::MoveConstruct(Impl.Pointer, OldAllocation, Num()); + Memory::MoveConstruct(Impl.Pointer, OldAllocation, Num()); Memory::Destruct(OldAllocation, Num()); Impl->Deallocate(OldAllocation); } /** @return The pointer to the underlying element storage. */ - NODISCARD FORCEINLINE ElementType* GetData() { return Impl.Pointer; } - NODISCARD FORCEINLINE const ElementType* GetData() const { return Impl.Pointer; } + NODISCARD FORCEINLINE FElementType* GetData() { return Impl.Pointer; } + NODISCARD FORCEINLINE const FElementType* GetData() const { return Impl.Pointer; } /** @return The iterator to the first or end element. */ - NODISCARD FORCEINLINE Iterator Begin() { return Iterator(this, Impl.Pointer); } - NODISCARD FORCEINLINE ConstIterator Begin() const { return ConstIterator(this, Impl.Pointer); } - NODISCARD FORCEINLINE Iterator End() { return Iterator(this, Impl.Pointer + Num()); } - NODISCARD FORCEINLINE ConstIterator End() const { return ConstIterator(this, Impl.Pointer + Num()); } + NODISCARD FORCEINLINE FIterator Begin() { return FIterator(this, Impl.Pointer); } + NODISCARD FORCEINLINE FConstIterator Begin() const { return FConstIterator(this, Impl.Pointer); } + NODISCARD FORCEINLINE FIterator End() { return FIterator(this, Impl.Pointer + Num()); } + NODISCARD FORCEINLINE FConstIterator End() const { return FConstIterator(this, Impl.Pointer + Num()); } /** @return The reverse iterator to the first or end element. */ - NODISCARD FORCEINLINE ReverseIterator RBegin() { return ReverseIterator(End()); } - NODISCARD FORCEINLINE ConstReverseIterator RBegin() const { return ConstReverseIterator(End()); } - NODISCARD FORCEINLINE ReverseIterator REnd() { return ReverseIterator(Begin()); } - NODISCARD FORCEINLINE ConstReverseIterator REnd() const { return ConstReverseIterator(Begin()); } + NODISCARD FORCEINLINE FReverseIterator RBegin() { return FReverseIterator(End()); } + NODISCARD FORCEINLINE FConstReverseIterator RBegin() const { return FConstReverseIterator(End()); } + NODISCARD FORCEINLINE FReverseIterator REnd() { return FReverseIterator(Begin()); } + NODISCARD FORCEINLINE FConstReverseIterator REnd() const { return FConstReverseIterator(Begin()); } /** @return The number of elements in the container. */ NODISCARD FORCEINLINE size_t Num() const { return Impl.ArrayNum; } @@ -895,17 +895,17 @@ public: NODISCARD FORCEINLINE bool IsEmpty() const { return Num() == 0; } /** @return true if the iterator is valid, false otherwise. */ - NODISCARD FORCEINLINE bool IsValidIterator(ConstIterator Iter) const { return Begin() <= Iter && Iter <= End(); } + NODISCARD FORCEINLINE bool IsValidIterator(FConstIterator Iter) const { return Begin() <= Iter && Iter <= End(); } /** @return The reference to the requested element. */ - NODISCARD FORCEINLINE ElementType& operator[](size_t Index) { checkf(Index < Num(), TEXT("Read access violation. Please check IsValidIterator().")); return Impl.Pointer[Index]; } - NODISCARD FORCEINLINE const ElementType& operator[](size_t Index) const { checkf(Index < Num(), TEXT("Read access violation. Please check IsValidIterator().")); return Impl.Pointer[Index]; } + NODISCARD FORCEINLINE FElementType& operator[](size_t Index) { checkf(Index < Num(), TEXT("Read access violation. Please check IsValidIterator().")); return Impl.Pointer[Index]; } + NODISCARD FORCEINLINE const FElementType& operator[](size_t Index) const { checkf(Index < Num(), TEXT("Read access violation. Please check IsValidIterator().")); return Impl.Pointer[Index]; } /** @return The reference to the first or last element. */ - NODISCARD FORCEINLINE ElementType& Front() { return *Begin(); } - NODISCARD FORCEINLINE const ElementType& Front() const { return *Begin(); } - NODISCARD FORCEINLINE ElementType& Back() { return *(End() - 1); } - NODISCARD FORCEINLINE const ElementType& Back() const { return *(End() - 1); } + NODISCARD FORCEINLINE FElementType& Front() { return *Begin(); } + NODISCARD FORCEINLINE const FElementType& Front() const { return *Begin(); } + NODISCARD FORCEINLINE FElementType& Back() { return *(End() - 1); } + NODISCARD FORCEINLINE const FElementType& Back() const { return *(End() - 1); } /** Erases all elements from the container. After this call, Num() returns zero. */ void Reset(bool bAllowShrinking = true) @@ -929,11 +929,11 @@ public: } /** Overloads the GetTypeHash algorithm for TArray. */ - NODISCARD friend FORCEINLINE size_t GetTypeHash(const TArray& A) requires (CHashable) + NODISCARD friend FORCEINLINE size_t GetTypeHash(const TArray& A) requires (CHashable) { size_t Result = 0; - for (ConstIterator Iter = A.Begin(); Iter != A.End(); ++Iter) + for (FConstIterator Iter = A.Begin(); Iter != A.End(); ++Iter) { Result = HashCombine(Result, GetTypeHash(*Iter)); } @@ -942,7 +942,7 @@ public: } /** Overloads the Swap algorithm for TArray. */ - friend void Swap(TArray& A, TArray& B) requires (CMovable) + friend void Swap(TArray& A, TArray& B) requires (CMovable) { const bool bIsTransferable = A.Impl->IsTransferable(A.Impl.Pointer) && @@ -966,13 +966,13 @@ public: private: - ALLOCATOR_WRAPPER_BEGIN(AllocatorType, ElementType, Impl) + ALLOCATOR_WRAPPER_BEGIN(FAllocatorType, FElementType, Impl) { size_t ArrayNum; size_t ArrayMax; - ElementType* Pointer; + FElementType* Pointer; } - ALLOCATOR_WRAPPER_END(AllocatorType, ElementType, Impl) + ALLOCATOR_WRAPPER_END(FAllocatorType, FElementType, Impl) private: @@ -981,7 +981,7 @@ private: { public: - using ElementType = TRemoveCV; + using FElementType = TRemoveCV; FORCEINLINE TIteratorImpl() = default; diff --git a/Redcraft.Utility/Source/Public/Containers/ArrayView.h b/Redcraft.Utility/Source/Public/Containers/ArrayView.h index 9de400f..46b2688 100644 --- a/Redcraft.Utility/Source/Public/Containers/ArrayView.h +++ b/Redcraft.Utility/Source/Public/Containers/ArrayView.h @@ -29,15 +29,15 @@ class TArrayView { public: - using ElementType = T; + using FElementType = T; - using Reference = T&; + using FReference = T&; - class Iterator; + class FIterator; - using ReverseIterator = TReverseIterator; + using FReverseIterator = TReverseIterator; - static_assert(CContiguousIterator); + static_assert(CContiguousIterator); static constexpr size_t Extent = InExtent; @@ -53,7 +53,7 @@ public: } /** Constructs an array view that is a view over the range ['InFirst', 'InFirst' + 'Count'). */ - template requires (CConvertibleTo(*)[], ElementType(*)[]>) + template requires (CConvertibleTo(*)[], FElementType(*)[]>) FORCEINLINE constexpr explicit (Extent != DynamicExtent) TArrayView(I InFirst, size_t InCount) { checkf(Extent == DynamicExtent || Extent == InCount, TEXT("Illegal range count. Please check InCount.")); @@ -67,7 +67,7 @@ public: } /** Constructs an array view that is a view over the range ['InFirst', 'InLast'). */ - template S> requires (CConvertibleTo(*)[], ElementType(*)[]>) + template S> requires (CConvertibleTo(*)[], FElementType(*)[]>) FORCEINLINE constexpr explicit (Extent != DynamicExtent) TArrayView(I InFirst, S InLast) { checkf(Extent == DynamicExtent || Extent == InLast - InFirst, TEXT("Illegal range iterator. Please check InLast - InFirst.")); @@ -82,7 +82,7 @@ public: /** Constructs an array view that is a view over the array 'InArray'. */ template requires (Extent == DynamicExtent || N == Extent) - FORCEINLINE constexpr TArrayView(ElementType(&InArray)[N]) + FORCEINLINE constexpr TArrayView(FElementType(&InArray)[N]) { Impl.Pointer = InArray; @@ -93,23 +93,23 @@ public: } /** Constructs an array view that is a view over the array 'InArray'. */ - template requires (CConvertibleTo) + template requires (CConvertibleTo) FORCEINLINE constexpr TArrayView(TStaticArray& InArray) : TArrayView(InArray.GetData(), InArray.Num()) { } /** Constructs an array view that is a view over the array 'InArray'. */ - template requires (CConvertibleTo) + template requires (CConvertibleTo) FORCEINLINE constexpr TArrayView(const TStaticArray& InArray) : TArrayView(InArray.GetData(), InArray.Num()) { } /** Constructs an array view that is a view over the array 'InArray'. */ - template requires (CConvertibleTo) + template requires (CConvertibleTo) FORCEINLINE constexpr TArrayView(TArray& InArray) : TArrayView(InArray.GetData(), InArray.Num()) { } /** Constructs an array view that is a view over the array 'InArray'. */ - template requires (CConvertibleTo) + template requires (CConvertibleTo) FORCEINLINE constexpr TArrayView(const TArray& InArray) : TArrayView(InArray.GetData(), InArray.Num()) { } /** Converting constructor from another array view 'InValue'. */ - template requires ((Extent == DynamicExtent || N == DynamicExtent || N == Extent) && CConvertibleTo) + template requires ((Extent == DynamicExtent || N == DynamicExtent || N == Extent) && CConvertibleTo) FORCEINLINE constexpr explicit (Extent != DynamicExtent && N == DynamicExtent) TArrayView(TArrayView InValue) { checkf(Extent == DynamicExtent || Extent == InValue.Num(), TEXT("Illegal view extent. Please check InValue.Num().")); @@ -129,7 +129,7 @@ public: FORCEINLINE constexpr TArrayView& operator=(const TArrayView&) noexcept = default; /** Compares the contents of two array views. */ - NODISCARD friend constexpr bool operator==(TArrayView LHS, TArrayView RHS) requires (CWeaklyEqualityComparable) + NODISCARD friend constexpr bool operator==(TArrayView LHS, TArrayView RHS) requires (CWeaklyEqualityComparable) { if (LHS.Num() != RHS.Num()) return false; @@ -142,7 +142,7 @@ public: } /** Compares the contents of two array views. */ - NODISCARD friend constexpr auto operator<=>(TArrayView LHS, TArrayView RHS) requires (CSynthThreeWayComparable) + NODISCARD friend constexpr auto operator<=>(TArrayView LHS, TArrayView RHS) requires (CSynthThreeWayComparable) { const size_t NumToCompare = LHS.Num() < RHS.Num() ? LHS.Num() : RHS.Num(); @@ -156,36 +156,36 @@ public: /** Obtains an array view that is a view over the first 'Count' elements of this array view. */ template requires (Extent == DynamicExtent || Extent >= Count) - NODISCARD FORCEINLINE constexpr TArrayView First() const + NODISCARD FORCEINLINE constexpr TArrayView First() const { checkf(Count <= Num(), TEXT("Illegal subview range. Please check Count.")); - return TArrayView(Begin(), Count); + return TArrayView(Begin(), Count); } /** Obtains an array view that is a view over the first 'Count' elements of this array view. */ - NODISCARD FORCEINLINE constexpr TArrayView First(size_t Count) const + NODISCARD FORCEINLINE constexpr TArrayView First(size_t Count) const { checkf(Count <= Num(), TEXT("Illegal subview range. Please check Count.")); - return TArrayView(Begin(), Count); + return TArrayView(Begin(), Count); } /** Obtains an array view that is a view over the last 'Count' elements of this array view. */ template requires (Extent == DynamicExtent || Extent >= Count) - NODISCARD FORCEINLINE constexpr TArrayView Last() const + NODISCARD FORCEINLINE constexpr TArrayView Last() const { checkf(Count <= Num(), TEXT("Illegal subview range. Please check Count.")); - return TArrayView(End() - Count, Count); + return TArrayView(End() - Count, Count); } /** Obtains an array view that is a view over the last 'Count' elements of this array view. */ - NODISCARD FORCEINLINE constexpr TArrayView Last(size_t Count) const + NODISCARD FORCEINLINE constexpr TArrayView Last(size_t Count) const { checkf(Count <= Num(), TEXT("Illegal subview range. Please check Count.")); - return TArrayView(End() - Count, Count); + return TArrayView(End() - Count, Count); } /** Obtains an array view that is a view over the 'Count' elements of this array view starting at 'Offset'. */ @@ -198,11 +198,11 @@ public: if constexpr (Count != DynamicExtent) { - return TArrayView(Begin() + Offset, Count); + return TArrayView(Begin() + Offset, Count); } else { - return TArrayView(Begin() + Offset, Num() - Offset); + return TArrayView(Begin() + Offset, Num() - Offset); } } @@ -213,20 +213,20 @@ public: if (Count != DynamicExtent) { - return TArrayView(Begin() + Offset, Count); + return TArrayView(Begin() + Offset, Count); } else { - return TArrayView(Begin() + Offset, Num() - Offset); + return TArrayView(Begin() + Offset, Num() - Offset); } } /** Obtains an array view to the object representation of the elements of the array view. */ NODISCARD FORCEINLINE constexpr auto AsBytes() { - constexpr size_t BytesExtent = Extent != DynamicExtent ? sizeof(ElementType) * Extent : DynamicExtent; + constexpr size_t BytesExtent = Extent != DynamicExtent ? sizeof(FElementType) * Extent : DynamicExtent; - if constexpr (!CConst) + if constexpr (!CConst) { return TArrayView(reinterpret_cast(GetData()), NumBytes()); } @@ -239,47 +239,47 @@ public: /** Obtains an array view to the object representation of the elements of the array view. */ NODISCARD FORCEINLINE constexpr auto AsBytes() const { - constexpr size_t BytesExtent = Extent != DynamicExtent ? sizeof(ElementType) * Extent : DynamicExtent; + constexpr size_t BytesExtent = Extent != DynamicExtent ? sizeof(FElementType) * Extent : DynamicExtent; return TArrayView(reinterpret_cast(GetData()), NumBytes()); } /** @return The pointer to the underlying element storage. */ - NODISCARD FORCEINLINE constexpr ElementType* GetData() const { return Impl.Pointer; } + NODISCARD FORCEINLINE constexpr FElementType* GetData() const { return Impl.Pointer; } /** @return The iterator to the first or end element. */ - NODISCARD FORCEINLINE constexpr Iterator Begin() const { return Iterator(this, Impl.Pointer); } - NODISCARD FORCEINLINE constexpr Iterator End() const { return Iterator(this, Impl.Pointer + Num()); } + NODISCARD FORCEINLINE constexpr FIterator Begin() const { return FIterator(this, Impl.Pointer); } + NODISCARD FORCEINLINE constexpr FIterator End() const { return FIterator(this, Impl.Pointer + Num()); } /** @return The reverse iterator to the first or end element. */ - NODISCARD FORCEINLINE constexpr ReverseIterator RBegin() const { return ReverseIterator(End()); } - NODISCARD FORCEINLINE constexpr ReverseIterator REnd() const { return ReverseIterator(Begin()); } + NODISCARD FORCEINLINE constexpr FReverseIterator RBegin() const { return FReverseIterator(End()); } + NODISCARD FORCEINLINE constexpr FReverseIterator REnd() const { return FReverseIterator(Begin()); } /** @return The number of elements in the container. */ NODISCARD FORCEINLINE constexpr size_t Num() const { if constexpr (Extent == DynamicExtent) { return Impl.ArrayNum; } return Extent; } /** @return The number of bytes in the container. */ - NODISCARD FORCEINLINE constexpr size_t NumBytes() const { return Num() * sizeof(ElementType); } + NODISCARD FORCEINLINE constexpr size_t NumBytes() const { return Num() * sizeof(FElementType); } /** @return true if the container is empty, false otherwise. */ NODISCARD FORCEINLINE constexpr bool IsEmpty() const { return Num() == 0; } /** @return true if the iterator is valid, false otherwise. */ - NODISCARD FORCEINLINE constexpr bool IsValidIterator(Iterator Iter) const { return Begin() <= Iter && Iter <= End(); } + NODISCARD FORCEINLINE constexpr bool IsValidIterator(FIterator Iter) const { return Begin() <= Iter && Iter <= End(); } /** @return The reference to the requested element. */ - NODISCARD FORCEINLINE constexpr Reference operator[](size_t Index) const { checkf(Index < Num(), TEXT("Read access violation. Please check IsValidIterator().")); return Impl.Pointer[Index]; } + NODISCARD FORCEINLINE constexpr FReference operator[](size_t Index) const { checkf(Index < Num(), TEXT("Read access violation. Please check IsValidIterator().")); return Impl.Pointer[Index]; } /** @return The reference to the first or last element. */ - NODISCARD FORCEINLINE constexpr Reference Front() const { return *Begin(); } - NODISCARD FORCEINLINE constexpr Reference Back() const { return *(End() - 1); } + NODISCARD FORCEINLINE constexpr FReference Front() const { return *Begin(); } + NODISCARD FORCEINLINE constexpr FReference Back() const { return *(End() - 1); } /** Overloads the GetTypeHash algorithm for TArrayView. */ - NODISCARD friend FORCEINLINE constexpr size_t GetTypeHash(TArrayView A) requires (CHashable) + NODISCARD friend FORCEINLINE constexpr size_t GetTypeHash(TArrayView A) requires (CHashable) { size_t Result = 0; - for (Iterator Iter = A.Begin(); Iter != A.End(); ++Iter) + for (FIterator Iter = A.Begin(); Iter != A.End(); ++Iter) { Result = HashCombine(Result, GetTypeHash(*Iter)); } @@ -291,7 +291,7 @@ public: private: - struct FImplWithoutNum { ElementType* Pointer; }; + struct FImplWithoutNum { FElementType* Pointer; }; struct FImplWithNum : FImplWithoutNum { size_t ArrayNum; }; @@ -299,42 +299,42 @@ private: public: - class Iterator final + class FIterator final { public: - using ElementType = TRemoveCV; + using FElementType = TRemoveCV; - FORCEINLINE constexpr Iterator() = default; - FORCEINLINE constexpr Iterator(const Iterator&) = default; - FORCEINLINE constexpr Iterator(Iterator&&) = default; - FORCEINLINE constexpr Iterator& operator=(const Iterator&) = default; - FORCEINLINE constexpr Iterator& operator=(Iterator&&) = default; + FORCEINLINE constexpr FIterator() = default; + FORCEINLINE constexpr FIterator(const FIterator&) = default; + FORCEINLINE constexpr FIterator(FIterator&&) = default; + FORCEINLINE constexpr FIterator& operator=(const FIterator&) = default; + FORCEINLINE constexpr FIterator& operator=(FIterator&&) = default; - NODISCARD friend FORCEINLINE constexpr bool operator==(const Iterator& LHS, const Iterator& RHS) { return LHS.Pointer == RHS.Pointer; } + NODISCARD friend FORCEINLINE constexpr bool operator==(const FIterator& LHS, const FIterator& RHS) { return LHS.Pointer == RHS.Pointer; } - NODISCARD friend FORCEINLINE constexpr strong_ordering operator<=>(const Iterator& LHS, const Iterator& RHS) { return LHS.Pointer <=> RHS.Pointer; } + NODISCARD friend FORCEINLINE constexpr strong_ordering operator<=>(const FIterator& LHS, const FIterator& RHS) { return LHS.Pointer <=> RHS.Pointer; } NODISCARD FORCEINLINE constexpr T& operator*() const { CheckThis(true ); return *Pointer; } NODISCARD FORCEINLINE constexpr T* operator->() const { CheckThis(false); return Pointer; } - NODISCARD FORCEINLINE constexpr T& operator[](ptrdiff Index) const { Iterator Temp = *this + Index; return *Temp; } + NODISCARD FORCEINLINE constexpr T& operator[](ptrdiff Index) const { FIterator Temp = *this + Index; return *Temp; } - FORCEINLINE constexpr Iterator& operator++() { ++Pointer; CheckThis(); return *this; } - FORCEINLINE constexpr Iterator& operator--() { --Pointer; CheckThis(); return *this; } + FORCEINLINE constexpr FIterator& operator++() { ++Pointer; CheckThis(); return *this; } + FORCEINLINE constexpr FIterator& operator--() { --Pointer; CheckThis(); return *this; } - FORCEINLINE constexpr Iterator operator++(int) { Iterator Temp = *this; ++*this; return Temp; } - FORCEINLINE constexpr Iterator operator--(int) { Iterator Temp = *this; --*this; return Temp; } + FORCEINLINE constexpr FIterator operator++(int) { FIterator Temp = *this; ++*this; return Temp; } + FORCEINLINE constexpr FIterator operator--(int) { FIterator Temp = *this; --*this; return Temp; } - FORCEINLINE constexpr Iterator& operator+=(ptrdiff Offset) { Pointer += Offset; CheckThis(); return *this; } - FORCEINLINE constexpr Iterator& operator-=(ptrdiff Offset) { Pointer -= Offset; CheckThis(); return *this; } + FORCEINLINE constexpr FIterator& operator+=(ptrdiff Offset) { Pointer += Offset; CheckThis(); return *this; } + FORCEINLINE constexpr FIterator& operator-=(ptrdiff Offset) { Pointer -= Offset; CheckThis(); return *this; } - NODISCARD friend FORCEINLINE constexpr Iterator operator+(Iterator Iter, ptrdiff Offset) { Iterator Temp = Iter; Temp += Offset; return Temp; } - NODISCARD friend FORCEINLINE constexpr Iterator operator+(ptrdiff Offset, Iterator Iter) { Iterator Temp = Iter; Temp += Offset; return Temp; } + NODISCARD friend FORCEINLINE constexpr FIterator operator+(FIterator Iter, ptrdiff Offset) { FIterator Temp = Iter; Temp += Offset; return Temp; } + NODISCARD friend FORCEINLINE constexpr FIterator operator+(ptrdiff Offset, FIterator Iter) { FIterator Temp = Iter; Temp += Offset; return Temp; } - NODISCARD FORCEINLINE constexpr Iterator operator-(ptrdiff Offset) const { Iterator Temp = *this; Temp -= Offset; return Temp; } + NODISCARD FORCEINLINE constexpr FIterator operator-(ptrdiff Offset) const { FIterator Temp = *this; Temp -= Offset; return Temp; } - NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(const Iterator& LHS, const Iterator& RHS) { LHS.CheckThis(); RHS.CheckThis(); return LHS.Pointer - RHS.Pointer; } + NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(const FIterator& LHS, const FIterator& RHS) { LHS.CheckThis(); RHS.CheckThis(); return LHS.Pointer - RHS.Pointer; } private: @@ -345,11 +345,11 @@ public: T* Pointer = nullptr; # if DO_CHECK - FORCEINLINE constexpr Iterator(const TArrayView* InContainer, T* InPointer) + FORCEINLINE constexpr FIterator(const TArrayView* InContainer, T* InPointer) : Owner(InContainer), Pointer(InPointer) { } # else - FORCEINLINE constexpr Iterator(const TArrayView* InContainer, T* InPointer) + FORCEINLINE constexpr FIterator(const TArrayView* InContainer, T* InPointer) : Pointer(InPointer) { } # endif diff --git a/Redcraft.Utility/Source/Public/Containers/Bitset.h b/Redcraft.Utility/Source/Public/Containers/Bitset.h index e1bb78b..a233d57 100644 --- a/Redcraft.Utility/Source/Public/Containers/Bitset.h +++ b/Redcraft.Utility/Source/Public/Containers/Bitset.h @@ -30,23 +30,23 @@ private: public: - using BlockType = InBlockType; - using ElementType = bool; - using AllocatorType = Allocator; + using FBlockType = InBlockType; + using FElementType = bool; + using FAllocatorType = Allocator; - class Reference; - using ConstReference = bool; + class FReference; + using FConstReference = bool; - using Iterator = TIteratorImpl; - using ConstIterator = TIteratorImpl; + using FIterator = TIteratorImpl; + using FConstIterator = TIteratorImpl; - using ReverseIterator = TReverseIterator< Iterator>; - using ConstReverseIterator = TReverseIterator; + using FReverseIterator = TReverseIterator< FIterator>; + using FConstReverseIterator = TReverseIterator; - static_assert(CRandomAccessIterator< Iterator>); - static_assert(CRandomAccessIterator); + static_assert(CRandomAccessIterator< FIterator>); + static_assert(CRandomAccessIterator); - static constexpr size_t BlockWidth = sizeof(BlockType) * 8; + static constexpr size_t BlockWidth = sizeof(FBlockType) * 8; /** Default constructor. Constructs an empty bitset. */ FORCEINLINE TBitset() : TBitset(0) { } @@ -62,40 +62,40 @@ public: /** Constructs a bitset from an integer. */ TBitset(size_t InCount, uint64 InValue) : TBitset(InCount > 64 ? InCount : 64) { - static_assert(sizeof(BlockType) <= sizeof(uint64), "The block width of TBitset is unexpected"); + static_assert(sizeof(FBlockType) <= sizeof(uint64), "The block width of TBitset is unexpected"); - if constexpr (sizeof(BlockType) == sizeof(uint8)) + if constexpr (sizeof(FBlockType) == sizeof(uint8)) { - Impl.Pointer[0] = static_cast(InValue >> 0); - Impl.Pointer[1] = static_cast(InValue >> 8); - Impl.Pointer[2] = static_cast(InValue >> 16); - Impl.Pointer[3] = static_cast(InValue >> 24); - Impl.Pointer[4] = static_cast(InValue >> 32); - Impl.Pointer[5] = static_cast(InValue >> 40); - Impl.Pointer[6] = static_cast(InValue >> 48); - Impl.Pointer[7] = static_cast(InValue >> 56); + Impl.Pointer[0] = static_cast(InValue >> 0); + Impl.Pointer[1] = static_cast(InValue >> 8); + Impl.Pointer[2] = static_cast(InValue >> 16); + Impl.Pointer[3] = static_cast(InValue >> 24); + Impl.Pointer[4] = static_cast(InValue >> 32); + Impl.Pointer[5] = static_cast(InValue >> 40); + Impl.Pointer[6] = static_cast(InValue >> 48); + Impl.Pointer[7] = static_cast(InValue >> 56); } - else if constexpr (sizeof(BlockType) == sizeof(uint16)) + else if constexpr (sizeof(FBlockType) == sizeof(uint16)) { - Impl.Pointer[0] = static_cast(InValue >> 0); - Impl.Pointer[1] = static_cast(InValue >> 16); - Impl.Pointer[2] = static_cast(InValue >> 32); - Impl.Pointer[3] = static_cast(InValue >> 48); + Impl.Pointer[0] = static_cast(InValue >> 0); + Impl.Pointer[1] = static_cast(InValue >> 16); + Impl.Pointer[2] = static_cast(InValue >> 32); + Impl.Pointer[3] = static_cast(InValue >> 48); } - else if constexpr (sizeof(BlockType) == sizeof(uint32)) + else if constexpr (sizeof(FBlockType) == sizeof(uint32)) { - Impl.Pointer[0] = static_cast(InValue >> 0); - Impl.Pointer[1] = static_cast(InValue >> 32); + Impl.Pointer[0] = static_cast(InValue >> 0); + Impl.Pointer[1] = static_cast(InValue >> 32); } - else if constexpr (sizeof(BlockType) == sizeof(uint64)) + else if constexpr (sizeof(FBlockType) == sizeof(uint64)) { - Impl.Pointer[0] = static_cast(InValue >> 0); + Impl.Pointer[0] = static_cast(InValue >> 0); } else check_no_entry(); - size_t BlockInteger = sizeof(uint64) / sizeof(BlockType); + size_t BlockInteger = sizeof(uint64) / sizeof(FBlockType); - Memory::Memset(Impl.Pointer + BlockInteger, 0, (NumBlocks() - BlockInteger) * sizeof(BlockType)); + Memory::Memset(Impl.Pointer + BlockInteger, 0, (NumBlocks() - BlockInteger) * sizeof(FBlockType)); Impl.BitsetNum = InCount; } @@ -112,9 +112,7 @@ public: new (this) TBitset(InCount); - BlockType* CurrentBlock = Impl.Pointer - 1; - - for (Reference Ref: *this) Ref = *First++; + for (FReference Ref: *this) Ref = *First++; } else { @@ -135,7 +133,7 @@ public: Impl.BlocksMax = Impl->CalculateSlackReserve(NumBlocks()); Impl.Pointer = Impl->Allocate(MaxBlocks()); - Memory::Memcpy(Impl.Pointer, InValue.Impl.Pointer, NumBlocks() * sizeof(BlockType)); + Memory::Memcpy(Impl.Pointer, InValue.Impl.Pointer, NumBlocks() * sizeof(FBlockType)); } /** Move constructor. After the move, 'InValue' is guaranteed to be empty. */ @@ -157,7 +155,7 @@ public: Impl.BlocksMax = Impl->CalculateSlackReserve(NumBlocks()); Impl.Pointer = Impl->Allocate(MaxBlocks()); - Memory::Memcpy(Impl.Pointer, InValue.Impl.Pointer, NumBlocks() * sizeof(BlockType)); + Memory::Memcpy(Impl.Pointer, InValue.Impl.Pointer, NumBlocks() * sizeof(FBlockType)); } } @@ -188,7 +186,7 @@ public: Impl.BlocksMax = NumToAllocate; Impl.Pointer = Impl->Allocate(MaxBlocks()); - Memory::Memcpy(Impl.Pointer, InValue.Impl.Pointer, NumBlocks() * sizeof(BlockType)); + Memory::Memcpy(Impl.Pointer, InValue.Impl.Pointer, NumBlocks() * sizeof(FBlockType)); return *this; } @@ -197,7 +195,7 @@ public: Impl.BitsetNum = InValue.Num(); - Memory::Memcpy(Impl.Pointer, InValue.Impl.Pointer, NumBlocks() * sizeof(BlockType)); + Memory::Memcpy(Impl.Pointer, InValue.Impl.Pointer, NumBlocks() * sizeof(FBlockType)); return *this; } @@ -247,14 +245,14 @@ public: Impl.BlocksMax = NumToAllocate; Impl.Pointer = Impl->Allocate(MaxBlocks()); - for (Reference Ref : *this) Ref = *First++; + for (FReference Ref : *this) Ref = *First++; return *this; } Impl.BitsetNum = GetNum(IL); - for (Reference Ref : *this) Ref = *First++; + for (FReference Ref : *this) Ref = *First++; return *this; } @@ -271,7 +269,7 @@ public: if (LHS.Impl.Pointer[Index] != RHS.Impl.Pointer[Index]) return false; } - const BlockType LastBlockBitmask = LHS.Num() % BlockWidth != 0 ? (1ull << LHS.Num() % BlockWidth) - 1 : -1; + const FBlockType LastBlockBitmask = LHS.Num() % BlockWidth != 0 ? (1ull << LHS.Num() % BlockWidth) - 1 : -1; return (LHS.Impl.Pointer[LHS.NumBlocks() - 1] & LastBlockBitmask) == (RHS.Impl.Pointer[LHS.NumBlocks() - 1] & LastBlockBitmask); } @@ -301,7 +299,7 @@ public: Impl.Pointer[Index] &= InValue.Impl.Pointer[Index]; } - const BlockType LastBlockBitmask = InValue.Num() % BlockWidth != 0 ? (1ull << InValue.Num() % BlockWidth) - 1 : -1; + const FBlockType LastBlockBitmask = InValue.Num() % BlockWidth != 0 ? (1ull << InValue.Num() % BlockWidth) - 1 : -1; Impl.Pointer[LastBlock] &= InValue.Impl.Pointer[LastBlock] & LastBlockBitmask; @@ -339,7 +337,7 @@ public: Impl.Pointer[Index] |= InValue.Impl.Pointer[Index]; } - const BlockType LastBlockBitmask = InValue.Num() % BlockWidth != 0 ? (1ull << InValue.Num() % BlockWidth) - 1 : -1; + const FBlockType LastBlockBitmask = InValue.Num() % BlockWidth != 0 ? (1ull << InValue.Num() % BlockWidth) - 1 : -1; Impl.Pointer[LastBlock] |= InValue.Impl.Pointer[LastBlock] & LastBlockBitmask; } @@ -372,7 +370,7 @@ public: Impl.Pointer[Index] ^= InValue.Impl.Pointer[Index]; } - const BlockType LastBlockBitmask = InValue.Num() % BlockWidth != 0 ? (1ull << InValue.Num() % BlockWidth) - 1 : -1; + const FBlockType LastBlockBitmask = InValue.Num() % BlockWidth != 0 ? (1ull << InValue.Num() % BlockWidth) - 1 : -1; Impl.Pointer[LastBlock] ^= InValue.Impl.Pointer[LastBlock] & LastBlockBitmask; } @@ -473,7 +471,7 @@ public: if (Impl.Pointer[Index] != -1) return false; } - const BlockType LastBlockBitmask = Num() % BlockWidth != 0 ? (1ull << Num() % BlockWidth) - 1 : -1; + const FBlockType LastBlockBitmask = Num() % BlockWidth != 0 ? (1ull << Num() % BlockWidth) - 1 : -1; return (Impl.Pointer[NumBlocks() - 1] | ~LastBlockBitmask) == -1; } @@ -488,7 +486,7 @@ public: if (Impl.Pointer[Index] != 0) return true; } - const BlockType LastBlockBitmask = Num() % BlockWidth != 0 ? (1ull << Num() % BlockWidth) - 1 : -1; + const FBlockType LastBlockBitmask = Num() % BlockWidth != 0 ? (1ull << Num() % BlockWidth) - 1 : -1; return (Impl.Pointer[NumBlocks() - 1] & LastBlockBitmask) != 0; } @@ -503,24 +501,24 @@ public: size_t Result = 0; - constexpr auto BlockCount = [](BlockType Block) + constexpr auto BlockCount = [](FBlockType Block) { - static_assert(sizeof(BlockType) <= sizeof(uint64), "The block width of TBitset is unexpected"); + static_assert(sizeof(FBlockType) <= sizeof(uint64), "The block width of TBitset is unexpected"); - if constexpr (sizeof(BlockType) == sizeof(uint8)) + if constexpr (sizeof(FBlockType) == sizeof(uint8)) { Block = (Block & 0x55ull) + ((Block >> 1) & 0x55ull); Block = (Block & 0x33ull) + ((Block >> 2) & 0x33ull); Block = (Block & 0x0Full) + ((Block >> 4) & 0x0Full); } - else if constexpr (sizeof(BlockType) == sizeof(uint16)) + else if constexpr (sizeof(FBlockType) == sizeof(uint16)) { Block = (Block & 0x5555ull) + ((Block >> 1) & 0x5555ull); Block = (Block & 0x3333ull) + ((Block >> 2) & 0x3333ull); Block = (Block & 0x0F0Full) + ((Block >> 4) & 0x0F0Full); Block = (Block & 0x00FFull) + ((Block >> 8) & 0x00FFull); } - else if constexpr (sizeof(BlockType) == sizeof(uint32)) + else if constexpr (sizeof(FBlockType) == sizeof(uint32)) { Block = (Block & 0x55555555ull) + ((Block >> 1) & 0x55555555ull); Block = (Block & 0x33333333ull) + ((Block >> 2) & 0x33333333ull); @@ -528,7 +526,7 @@ public: Block = (Block & 0x00FF00FFull) + ((Block >> 8) & 0x00FF00FFull); Block = (Block & 0x0000FFFFull) + ((Block >> 16) & 0x0000FFFFull); } - else if constexpr (sizeof(BlockType) == sizeof(uint64)) + else if constexpr (sizeof(FBlockType) == sizeof(uint64)) { Block = (Block & 0x5555555555555555ull) + ((Block >> 1) & 0x5555555555555555ull); Block = (Block & 0x3333333333333333ull) + ((Block >> 2) & 0x3333333333333333ull); @@ -547,7 +545,7 @@ public: Result += BlockCount(Impl.Pointer[Index]); } - const BlockType LastBlockBitmask = Num() % BlockWidth != 0 ? (1ull << Num() % BlockWidth) - 1 : -1; + const FBlockType LastBlockBitmask = Num() % BlockWidth != 0 ? (1ull << Num() % BlockWidth) - 1 : -1; Result += BlockCount(Impl.Pointer[NumBlocks() - 1] & LastBlockBitmask); @@ -557,7 +555,7 @@ public: /** Sets all bits to true. */ TBitset& Set(bool InValue = true) { - Memory::Memset(Impl.Pointer, static_cast(InValue ? -1 : 0), NumBlocks() * sizeof(BlockType)); + Memory::Memset(Impl.Pointer, static_cast(InValue ? -1 : 0), NumBlocks() * sizeof(FBlockType)); return *this; } @@ -591,17 +589,17 @@ public: checkf(Impl.Pointer[Index] != 0, TEXT("The bitset can not be represented in uint64. Please check Num().")); } - const BlockType LastBlockBitmask = Num() % BlockWidth != 0 ? (1ull << Num() % BlockWidth) - 1 : -1; - const BlockType LastBlock = Impl.Pointer[NumBlocks() - 1] & LastBlockBitmask; + const FBlockType LastBlockBitmask = Num() % BlockWidth != 0 ? (1ull << Num() % BlockWidth) - 1 : -1; + const FBlockType LastBlock = Impl.Pointer[NumBlocks() - 1] & LastBlockBitmask; checkf(LastBlock != 0, TEXT("The bitset can not be represented in uint64. Please check Num().")); } uint64 Result = 0; - static_assert(sizeof(BlockType) <= sizeof(uint64), "The block width of TBitset is unexpected"); + static_assert(sizeof(FBlockType) <= sizeof(uint64), "The block width of TBitset is unexpected"); - if constexpr (sizeof(BlockType) == sizeof(uint8)) + if constexpr (sizeof(FBlockType) == sizeof(uint8)) { Result |= static_cast(Impl.Pointer[0]) << 0; Result |= static_cast(Impl.Pointer[1]) << 8; @@ -612,19 +610,19 @@ public: Result |= static_cast(Impl.Pointer[6]) << 48; Result |= static_cast(Impl.Pointer[7]) << 56; } - else if constexpr (sizeof(BlockType) == sizeof(uint16)) + else if constexpr (sizeof(FBlockType) == sizeof(uint16)) { Result |= static_cast(Impl.Pointer[0]) << 0; Result |= static_cast(Impl.Pointer[1]) << 16; Result |= static_cast(Impl.Pointer[2]) << 32; Result |= static_cast(Impl.Pointer[3]) << 48; } - else if constexpr (sizeof(BlockType) == sizeof(uint32)) + else if constexpr (sizeof(FBlockType) == sizeof(uint32)) { Result |= static_cast(Impl.Pointer[0]) << 0; Result |= static_cast(Impl.Pointer[1]) << 32; } - else if constexpr (sizeof(BlockType) == sizeof(uint64)) + else if constexpr (sizeof(FBlockType) == sizeof(uint64)) { Result |= static_cast(Impl.Pointer[0]) << 0; } @@ -661,7 +659,7 @@ public: if (NumToAllocate != MaxBlocks()) { - BlockType* OldAllocation = Impl.Pointer; + FBlockType* OldAllocation = Impl.Pointer; const size_t NumToDestruct = NumBlocks(); Impl.BitsetNum = InCount; @@ -670,11 +668,11 @@ public: if (NumToDestruct <= Num()) { - Memory::Memcpy(Impl.Pointer, OldAllocation, NumToDestruct * sizeof(BlockType)); + Memory::Memcpy(Impl.Pointer, OldAllocation, NumToDestruct * sizeof(FBlockType)); } else { - Memory::Memcpy(Impl.Pointer, OldAllocation, BlocksCount * sizeof(BlockType)); + Memory::Memcpy(Impl.Pointer, OldAllocation, BlocksCount * sizeof(FBlockType)); } Impl->Deallocate(OldAllocation); @@ -697,12 +695,12 @@ public: NumToAllocate = NumToAllocate > MaxBlocks() ? Impl->CalculateSlackGrow(BlocksCount, MaxBlocks()) : NumToAllocate; NumToAllocate = NumToAllocate < MaxBlocks() ? (bAllowShrinking ? Impl->CalculateSlackShrink(BlocksCount, MaxBlocks()) : MaxBlocks()) : NumToAllocate; - const BlockType LastBlockBitmask = Num() % BlockWidth != 0 ? (1ull << Num() % BlockWidth) - 1 : -1; - const BlockType BlocksValueToSet = static_cast(InValue ? -1 : 0); + const FBlockType LastBlockBitmask = Num() % BlockWidth != 0 ? (1ull << Num() % BlockWidth) - 1 : -1; + const FBlockType BlocksValueToSet = static_cast(InValue ? -1 : 0); if (NumToAllocate != MaxBlocks()) { - BlockType* OldAllocation = Impl.Pointer; + FBlockType* OldAllocation = Impl.Pointer; const size_t NumToDestruct = NumBlocks(); Impl.BitsetNum = InCount; @@ -713,16 +711,16 @@ public: { if (NumToDestruct != 0) { - Memory::Memcpy(Impl.Pointer, OldAllocation, (NumToDestruct - 1) * sizeof(BlockType)); + Memory::Memcpy(Impl.Pointer, OldAllocation, (NumToDestruct - 1) * sizeof(FBlockType)); Impl.Pointer[NumToDestruct - 1] = OldAllocation[NumToDestruct - 1] & LastBlockBitmask | BlocksValueToSet & ~LastBlockBitmask; } - Memory::Memset(Impl.Pointer + NumToDestruct, static_cast(BlocksValueToSet), (BlocksCount - NumToDestruct) * sizeof(BlockType)); + Memory::Memset(Impl.Pointer + NumToDestruct, static_cast(BlocksValueToSet), (BlocksCount - NumToDestruct) * sizeof(FBlockType)); } else { - Memory::Memcpy(Impl.Pointer, OldAllocation, BlocksCount * sizeof(BlockType)); + Memory::Memcpy(Impl.Pointer, OldAllocation, BlocksCount * sizeof(FBlockType)); } Impl->Deallocate(OldAllocation); @@ -739,7 +737,7 @@ public: Impl.Pointer[NumBlocks() - 1] = Impl.Pointer[NumBlocks() - 1] & LastBlockBitmask | BlocksValueToSet & ~LastBlockBitmask; } - Memory::Memset(Impl.Pointer + NumBlocks(), static_cast(BlocksValueToSet), (BlocksCount - NumBlocks()) * sizeof(BlockType)); + Memory::Memset(Impl.Pointer + NumBlocks(), static_cast(BlocksValueToSet), (BlocksCount - NumBlocks()) * sizeof(FBlockType)); } Impl.BitsetNum = InCount; @@ -753,14 +751,14 @@ public: const size_t BlocksCount = (InCount + BlockWidth - 1) / BlockWidth; const size_t NumToAllocate = Impl->CalculateSlackReserve(BlocksCount); - BlockType* OldAllocation = Impl.Pointer; + FBlockType* OldAllocation = Impl.Pointer; check(NumToAllocate > MaxBlocks()); Impl.BlocksMax = NumToAllocate; Impl.Pointer = Impl->Allocate(MaxBlocks()); - Memory::Memcpy(Impl.Pointer, OldAllocation, NumBlocks() * sizeof(BlockType)); + Memory::Memcpy(Impl.Pointer, OldAllocation, NumBlocks() * sizeof(FBlockType)); Impl->Deallocate(OldAllocation); } @@ -774,31 +772,31 @@ public: if (NumToAllocate == MaxBlocks()) return; - BlockType* OldAllocation = Impl.Pointer; + FBlockType* OldAllocation = Impl.Pointer; Impl.BitsetNum = NumToAllocate * BlockWidth; Impl.Pointer = Impl->Allocate(MaxBlocks()); - Memory::Memcpy(Impl.Pointer, OldAllocation, NumBlocks() * sizeof(BlockType)); + Memory::Memcpy(Impl.Pointer, OldAllocation, NumBlocks() * sizeof(FBlockType)); Impl->Deallocate(OldAllocation); } /** @return The pointer to the underlying element storage. */ - NODISCARD FORCEINLINE BlockType* GetData() { return Impl.Pointer; } - NODISCARD FORCEINLINE const BlockType* GetData() const { return Impl.Pointer; } + NODISCARD FORCEINLINE FBlockType* GetData() { return Impl.Pointer; } + NODISCARD FORCEINLINE const FBlockType* GetData() const { return Impl.Pointer; } /** @return The iterator to the first or end bit. */ - NODISCARD FORCEINLINE Iterator Begin() { return Iterator(this, Impl.Pointer, 0); } - NODISCARD FORCEINLINE ConstIterator Begin() const { return ConstIterator(this, Impl.Pointer, 0); } - NODISCARD FORCEINLINE Iterator End() { return Iterator(this, Impl.Pointer, Num()); } - NODISCARD FORCEINLINE ConstIterator End() const { return ConstIterator(this, Impl.Pointer, Num()); } + NODISCARD FORCEINLINE FIterator Begin() { return FIterator(this, Impl.Pointer, 0); } + NODISCARD FORCEINLINE FConstIterator Begin() const { return FConstIterator(this, Impl.Pointer, 0); } + NODISCARD FORCEINLINE FIterator End() { return FIterator(this, Impl.Pointer, Num()); } + NODISCARD FORCEINLINE FConstIterator End() const { return FConstIterator(this, Impl.Pointer, Num()); } /** @return The reverse iterator to the first or end bit. */ - NODISCARD FORCEINLINE ReverseIterator RBegin() { return ReverseIterator(End()); } - NODISCARD FORCEINLINE ConstReverseIterator RBegin() const { return ConstReverseIterator(End()); } - NODISCARD FORCEINLINE ReverseIterator REnd() { return ReverseIterator(Begin()); } - NODISCARD FORCEINLINE ConstReverseIterator REnd() const { return ConstReverseIterator(Begin()); } + NODISCARD FORCEINLINE FReverseIterator RBegin() { return FReverseIterator(End()); } + NODISCARD FORCEINLINE FConstReverseIterator RBegin() const { return FConstReverseIterator(End()); } + NODISCARD FORCEINLINE FReverseIterator REnd() { return FReverseIterator(Begin()); } + NODISCARD FORCEINLINE FConstReverseIterator REnd() const { return FConstReverseIterator(Begin()); } /** @return The number of bits in the bitset. */ NODISCARD FORCEINLINE size_t Num() const { return Impl.BitsetNum; } @@ -816,17 +814,17 @@ public: NODISCARD FORCEINLINE bool IsEmpty() const { return Num() == 0; } /** @return true if the iterator is valid, false otherwise. */ - NODISCARD FORCEINLINE bool IsValidIterator(ConstIterator Iter) const { return Begin() <= Iter && Iter <= End(); } + NODISCARD FORCEINLINE bool IsValidIterator(FConstIterator Iter) const { return Begin() <= Iter && Iter <= End(); } /** @return The reference to the requested bit. */ - NODISCARD FORCEINLINE Reference operator[](size_t Index) { checkf(Index < Num(), TEXT("Read access violation. Please check IsValidIterator().")); return *(Begin() + Index); } - NODISCARD FORCEINLINE ConstReference operator[](size_t Index) const { checkf(Index < Num(), TEXT("Read access violation. Please check IsValidIterator().")); return *(Begin() + Index); } + NODISCARD FORCEINLINE FReference operator[](size_t Index) { checkf(Index < Num(), TEXT("Read access violation. Please check IsValidIterator().")); return *(Begin() + Index); } + NODISCARD FORCEINLINE FConstReference operator[](size_t Index) const { checkf(Index < Num(), TEXT("Read access violation. Please check IsValidIterator().")); return *(Begin() + Index); } /** @return The reference to the first or last bit. */ - NODISCARD FORCEINLINE Reference Front() { return *Begin(); } - NODISCARD FORCEINLINE ConstReference Front() const { return *Begin(); } - NODISCARD FORCEINLINE Reference Back() { return *(End() - 1); } - NODISCARD FORCEINLINE ConstReference Back() const { return *(End() - 1); } + NODISCARD FORCEINLINE FReference Front() { return *Begin(); } + NODISCARD FORCEINLINE FConstReference Front() const { return *Begin(); } + NODISCARD FORCEINLINE FReference Back() { return *(End() - 1); } + NODISCARD FORCEINLINE FConstReference Back() const { return *(End() - 1); } /** Erases all bits from the bitset. After this call, Num() returns zero. */ void Reset(bool bAllowShrinking = true) @@ -859,7 +857,7 @@ public: Result = HashCombine(Result, GetTypeHash(A.Impl.Pointer[Index])); } - const BlockType LastBlockBitmask = A.Num() % BlockWidth != 0 ? (1ull << A.Num() % BlockWidth) - 1 : -1; + const FBlockType LastBlockBitmask = A.Num() % BlockWidth != 0 ? (1ull << A.Num() % BlockWidth) - 1 : -1; return HashCombine(Result, GetTypeHash(A.Impl.Pointer[A.NumBlocks() - 1] & LastBlockBitmask)); } @@ -889,27 +887,27 @@ public: private: - ALLOCATOR_WRAPPER_BEGIN(AllocatorType, BlockType, Impl) + ALLOCATOR_WRAPPER_BEGIN(FAllocatorType, FBlockType, Impl) { size_t BitsetNum; size_t BlocksMax; - BlockType* Pointer; + FBlockType* Pointer; } - ALLOCATOR_WRAPPER_END(AllocatorType, BlockType, Impl) + ALLOCATOR_WRAPPER_END(FAllocatorType, FBlockType, Impl) public: - class Reference final : private FSingleton + class FReference final : private FSingleton { public: - FORCEINLINE Reference& operator=(bool InValue) { Data = (Data & ~Mask) | (InValue ? Mask : 0); return *this; } + FORCEINLINE FReference& operator=(bool InValue) { Data = (Data & ~Mask) | (InValue ? Mask : 0); return *this; } - FORCEINLINE Reference& operator=(const Reference& InValue) { *this = static_cast(InValue); return *this; } + FORCEINLINE FReference& operator=(const FReference& InValue) { *this = static_cast(InValue); return *this; } - FORCEINLINE Reference& operator&=(bool InValue) { Data &= InValue ? -1 : ~Mask; return *this; } - FORCEINLINE Reference& operator|=(bool InValue) { Data |= InValue ? Mask : 0; return *this; } - FORCEINLINE Reference& operator^=(bool InValue) { *this = InValue ^ *this; return *this; } + FORCEINLINE FReference& operator&=(bool InValue) { Data &= InValue ? -1 : ~Mask; return *this; } + FORCEINLINE FReference& operator|=(bool InValue) { Data |= InValue ? Mask : 0; return *this; } + FORCEINLINE FReference& operator^=(bool InValue) { *this = InValue ^ *this; return *this; } FORCEINLINE bool operator~() const { return !*this; } @@ -917,14 +915,14 @@ public: private: - FORCEINLINE Reference(BlockType& InData, BlockType InMask) + FORCEINLINE FReference(FBlockType& InData, FBlockType InMask) : Data(InData), Mask(InMask) { } - BlockType& Data; - BlockType Mask; + FBlockType& Data; + FBlockType Mask; - friend Iterator; + friend FIterator; }; @@ -935,7 +933,7 @@ private: { public: - using ElementType = bool; + using FElementType = bool; FORCEINLINE TIteratorImpl() = default; @@ -958,8 +956,8 @@ private: NODISCARD friend FORCEINLINE strong_ordering operator<=>(const TIteratorImpl& LHS, const TIteratorImpl& RHS) { check(LHS.Pointer == RHS.Pointer); return LHS.BitOffset <=> RHS.BitOffset; } - NODISCARD FORCEINLINE Reference operator*() const requires (!bConst) { CheckThis(true); return Reference(*(Pointer + BitOffset / BlockWidth), 1ull << BitOffset % BlockWidth); } - NODISCARD FORCEINLINE ConstReference operator*() const requires ( bConst) { CheckThis(true); return (*(Pointer + BitOffset / BlockWidth) & (1ull << BitOffset % BlockWidth)); } + NODISCARD FORCEINLINE FReference operator*() const requires (!bConst) { CheckThis(true); return FReference(*(Pointer + BitOffset / BlockWidth), 1ull << BitOffset % BlockWidth); } + NODISCARD FORCEINLINE FConstReference operator*() const requires ( bConst) { CheckThis(true); return (*(Pointer + BitOffset / BlockWidth) & (1ull << BitOffset % BlockWidth)); } NODISCARD FORCEINLINE auto operator[](ptrdiff Index) const { TIteratorImpl Temp = *this + Index; return *Temp; } @@ -985,17 +983,17 @@ private: const TBitset* Owner = nullptr; # endif - using BlockPtr = TConditional; + using FBlockPtr = TConditional; - BlockPtr Pointer = nullptr; - size_t BitOffset = 0; + FBlockPtr Pointer = nullptr; + size_t BitOffset = 0; # if DO_CHECK - FORCEINLINE TIteratorImpl(const TBitset* InContainer, BlockPtr InPointer, size_t Offset) + FORCEINLINE TIteratorImpl(const TBitset* InContainer, FBlockPtr InPointer, size_t Offset) : Owner(InContainer), Pointer(InPointer), BitOffset(Offset) { } # else - FORCEINLINE TIteratorImpl(const TBitset* InContainer, BlockPtr InPointer, size_t Offset) + FORCEINLINE TIteratorImpl(const TBitset* InContainer, FBlockPtr InPointer, size_t Offset) : Pointer(InPointer), BitOffset(Offset) { } # endif diff --git a/Redcraft.Utility/Source/Public/Containers/List.h b/Redcraft.Utility/Source/Public/Containers/List.h index 4425b01..785ff56 100644 --- a/Redcraft.Utility/Source/Public/Containers/List.h +++ b/Redcraft.Utility/Source/Public/Containers/List.h @@ -28,20 +28,20 @@ private: public: - using ElementType = T; - using AllocatorType = Allocator; + using FElementType = T; + using FAllocatorType = Allocator; - using Reference = T&; - using ConstReference = const T&; + using FReference = T&; + using FConstReference = const T&; - using Iterator = TIteratorImpl; - using ConstIterator = TIteratorImpl; + using FIterator = TIteratorImpl; + using FConstIterator = TIteratorImpl; - using ReverseIterator = TReverseIterator< Iterator>; - using ConstReverseIterator = TReverseIterator; + using FReverseIterator = TReverseIterator< FIterator>; + using FConstReverseIterator = TReverseIterator; - static_assert(CBidirectionalIterator< Iterator>); - static_assert(CBidirectionalIterator); + static_assert(CBidirectionalIterator< FIterator>); + static_assert(CBidirectionalIterator); /** Default constructor. Constructs an empty container with a default-constructed allocator. */ TList() @@ -54,7 +54,7 @@ public: } /** Constructs the container with 'Count' default instances of T. */ - explicit TList(size_t Count) requires (CDefaultConstructible) : TList() + explicit TList(size_t Count) requires (CDefaultConstructible) : TList() { FNode* EndNode = Impl.HeadNode->PrevNode; @@ -75,12 +75,12 @@ public: } /** Constructs the container with 'Count' copies of elements with 'InValue'. */ - TList(size_t Count, const ElementType& InValue) requires (CCopyable) + TList(size_t Count, const FElementType& InValue) requires (CCopyable) : TList(MakeCountedConstantIterator(InValue, Count), DefaultSentinel) { } /** Constructs the container with the contents of the range ['First', 'Last'). */ - template S> requires (CConstructibleFrom>) + template S> requires (CConstructibleFrom>) TList(I First, S Last) : TList() { FNode* EndNode = Impl.HeadNode->PrevNode; @@ -102,13 +102,13 @@ public: } /** Copy constructor. Constructs the container with the copy of the contents of 'InValue'. */ - FORCEINLINE TList(const TList& InValue) requires (CCopyConstructible) : TList(InValue.Begin(), InValue.End()) { } + FORCEINLINE TList(const TList& InValue) requires (CCopyConstructible) : TList(InValue.Begin(), InValue.End()) { } /** Move constructor. After the move, 'InValue' is guaranteed to be empty. */ FORCEINLINE TList(TList&& InValue) : TList() { Swap(*this, InValue); } /** Constructs the container with the contents of the initializer list. */ - FORCEINLINE TList(initializer_list IL) requires (CCopyConstructible) : TList(Iteration::Begin(IL), Iteration::End(IL)) { } + FORCEINLINE TList(initializer_list IL) requires (CCopyConstructible) : TList(Iteration::Begin(IL), Iteration::End(IL)) { } /** Destructs the list. The destructors of the elements are called and the used storage is deallocated. */ ~TList() @@ -129,12 +129,12 @@ public: } /** Copy assignment operator. Replaces the contents with a copy of the contents of 'InValue'. */ - TList& operator=(const TList& InValue) requires (CCopyable) + TList& operator=(const TList& InValue) requires (CCopyable) { if (&InValue == this) UNLIKELY return *this; - Iterator ThisIter = Begin(); - ConstIterator OtherIter = InValue.Begin(); + FIterator ThisIter = Begin(); + FConstIterator OtherIter = InValue.Begin(); while (ThisIter != End() && OtherIter != InValue.End()) { @@ -166,10 +166,10 @@ public: FORCEINLINE TList& operator=(TList&& InValue) { Swap(*this, InValue); InValue.Reset(); return *this; } /** Replaces the contents with those identified by initializer list. */ - TList& operator=(initializer_list IL) requires (CCopyable) + TList& operator=(initializer_list IL) requires (CCopyable) { - Iterator ThisIter = Begin(); - const ElementType* OtherIter = Iteration::Begin(IL); + FIterator ThisIter = Begin(); + const FElementType* OtherIter = Iteration::Begin(IL); while (ThisIter != End() && OtherIter != Iteration::End(IL)) { @@ -198,12 +198,12 @@ public: } /** Compares the contents of two lists. */ - NODISCARD friend bool operator==(const TList& LHS, const TList& RHS) requires (CWeaklyEqualityComparable) + NODISCARD friend bool operator==(const TList& LHS, const TList& RHS) requires (CWeaklyEqualityComparable) { if (LHS.Num() != RHS.Num()) return false; - ConstIterator LHSIter = LHS.Begin(); - ConstIterator RHSIter = RHS.Begin(); + FConstIterator LHSIter = LHS.Begin(); + FConstIterator RHSIter = RHS.Begin(); while (LHSIter != LHS.End()) { @@ -219,10 +219,10 @@ public: } /** Compares the contents of 'LHS' and 'RHS' lexicographically. */ - NODISCARD friend auto operator<=>(const TList& LHS, const TList& RHS) requires (CSynthThreeWayComparable) + NODISCARD friend auto operator<=>(const TList& LHS, const TList& RHS) requires (CSynthThreeWayComparable) { - ConstIterator LHSIter = LHS.Begin(); - ConstIterator RHSIter = RHS.Begin(); + FConstIterator LHSIter = LHS.Begin(); + FConstIterator RHSIter = RHS.Begin(); while (LHSIter != LHS.End() && RHSIter != RHS.End()) { @@ -236,22 +236,22 @@ public: } /** Inserts 'InValue' before 'Iter' in the container. */ - FORCEINLINE Iterator Insert(ConstIterator Iter, const ElementType& InValue) requires (CCopyConstructible) { return Emplace(Iter, InValue); } + FORCEINLINE FIterator Insert(FConstIterator Iter, const FElementType& InValue) requires (CCopyConstructible) { return Emplace(Iter, InValue); } /** Inserts 'InValue' before 'Iter' in the container. */ - FORCEINLINE Iterator Insert(ConstIterator Iter, ElementType&& InValue) requires (CMoveConstructible) { return Emplace(Iter, MoveTemp(InValue)); } + FORCEINLINE FIterator Insert(FConstIterator Iter, FElementType&& InValue) requires (CMoveConstructible) { return Emplace(Iter, MoveTemp(InValue)); } /** Inserts 'Count' copies of the 'InValue' before 'Iter' in the container. */ - Iterator Insert(ConstIterator Iter, size_t Count, const ElementType& InValue) requires (CCopyConstructible) + FIterator Insert(FConstIterator Iter, size_t Count, const FElementType& InValue) requires (CCopyConstructible) { return Insert(Iter, MakeCountedConstantIterator(InValue, Count), DefaultSentinel); } /** Inserts elements from range ['First', 'Last') before 'Iter'. */ - template S> requires (CConstructibleFrom>) - Iterator Insert(ConstIterator Iter, I First, S Last) + template S> requires (CConstructibleFrom>) + FIterator Insert(FConstIterator Iter, I First, S Last) { - if (First == Last) return Iterator(Iter.Pointer); + if (First == Last) return FIterator(Iter.Pointer); FNode* InsertNode = Iter.Pointer->PrevNode; @@ -279,15 +279,15 @@ public: InsertNode->NextNode = Iter.Pointer; Iter.Pointer->PrevNode = InsertNode; - return Iterator(FirstNode); + return FIterator(FirstNode); } /** Inserts elements from initializer list before 'Iter' in the container. */ - FORCEINLINE Iterator Insert(ConstIterator Iter, initializer_list IL) requires (CCopyConstructible) { return Insert(Iter, Iteration::Begin(IL), Iteration::End(IL)); } + FORCEINLINE FIterator Insert(FConstIterator Iter, initializer_list IL) requires (CCopyConstructible) { return Insert(Iter, Iteration::Begin(IL), Iteration::End(IL)); } /** Inserts a new element into the container directly before 'Iter'. */ - template requires (CConstructibleFrom) - Iterator Emplace(ConstIterator Iter, Ts&&... Args) + template requires (CConstructibleFrom) + FIterator Emplace(FConstIterator Iter, Ts&&... Args) { FNode* Node = new (Impl->Allocate(1)) FNode(InPlace, Forward(Args)...); @@ -299,11 +299,11 @@ public: Node->PrevNode->NextNode = Node; Node->NextNode->PrevNode = Node; - return Iterator(Node); + return FIterator(Node); } /** Removes the element at 'Iter' in the container. */ - Iterator Erase(ConstIterator Iter) + FIterator Erase(FConstIterator Iter) { FNode* NodeToErase = Iter.Pointer; @@ -319,11 +319,11 @@ public: --Impl.ListNum; - return Iterator(NextNode); + return FIterator(NextNode); } /** Removes the elements in the range ['First', 'Last') in the container. */ - Iterator Erase(ConstIterator First, ConstIterator Last) + FIterator Erase(FConstIterator First, FConstIterator Last) { FNode* FirstToErase = First.Pointer; FNode* LastToErase = Last.Pointer; @@ -343,43 +343,43 @@ public: FirstToErase = NextNode; } - return Iterator(LastToErase); + return FIterator(LastToErase); } /** Appends the given element value to the end of the container. */ - FORCEINLINE void PushBack(const ElementType& InValue) requires (CCopyConstructible) { EmplaceBack(InValue); } + FORCEINLINE void PushBack(const FElementType& InValue) requires (CCopyConstructible) { EmplaceBack(InValue); } /** Appends the given element value to the end of the container. */ - FORCEINLINE void PushBack(ElementType&& InValue) requires (CMoveConstructible) { EmplaceBack(MoveTemp(InValue)); } + FORCEINLINE void PushBack(FElementType&& InValue) requires (CMoveConstructible) { EmplaceBack(MoveTemp(InValue)); } /** Appends a new element to the end of the container. */ - template requires (CConstructibleFrom) - FORCEINLINE Reference EmplaceBack(Ts&&... Args) { return *Emplace(End(), Forward(Args)...); } + template requires (CConstructibleFrom) + FORCEINLINE FReference EmplaceBack(Ts&&... Args) { return *Emplace(End(), Forward(Args)...); } /** Removes the last element of the container. The list cannot be empty. */ FORCEINLINE void PopBack() { Erase(--End()); } /** Prepends the given element value to the beginning of the container. */ - FORCEINLINE void PushFront(const ElementType& InValue) requires (CCopyConstructible) { EmplaceFront(InValue); } + FORCEINLINE void PushFront(const FElementType& InValue) requires (CCopyConstructible) { EmplaceFront(InValue); } /** Prepends the given element value to the beginning of the container. */ - FORCEINLINE void PushFront(ElementType&& InValue) requires (CMoveConstructible) { EmplaceFront(MoveTemp(InValue)); } + FORCEINLINE void PushFront(FElementType&& InValue) requires (CMoveConstructible) { EmplaceFront(MoveTemp(InValue)); } /** Prepends a new element to the beginning of the container. */ - template requires (CConstructibleFrom) - FORCEINLINE Reference EmplaceFront(Ts&&... Args) { return *Emplace(Begin(), Forward(Args)...); } + template requires (CConstructibleFrom) + FORCEINLINE FReference EmplaceFront(Ts&&... Args) { return *Emplace(Begin(), Forward(Args)...); } /** Removes the first element of the container. The list cannot be empty. */ FORCEINLINE void PopFront() { Erase(Begin()); } /** Resizes the container to contain 'Count' elements. Additional default elements are appended. */ - void SetNum(size_t Count) requires (CDefaultConstructible) + void SetNum(size_t Count) requires (CDefaultConstructible) { if (Count == Impl.ListNum) return; if (Count < Impl.ListNum) { - Iterator First = End(); + FIterator First = End(); Iteration::Advance(First, Count - Impl.ListNum); @@ -409,13 +409,13 @@ public: } /** Resizes the container to contain 'Count' elements. Additional copies of 'InValue' are appended. */ - void SetNum(size_t Count, const ElementType& InValue) requires (CCopyConstructible) + void SetNum(size_t Count, const FElementType& InValue) requires (CCopyConstructible) { if (Count == Impl.ListNum) return; if (Count < Impl.ListNum) { - Iterator First = End(); + FIterator First = End(); Iteration::Advance(First, Count - Impl.ListNum); @@ -445,16 +445,16 @@ public: } /** @return The iterator to the first or end element. */ - NODISCARD FORCEINLINE Iterator Begin() { return Iterator(Impl.HeadNode->NextNode); } - NODISCARD FORCEINLINE ConstIterator Begin() const { return ConstIterator(Impl.HeadNode->NextNode); } - NODISCARD FORCEINLINE Iterator End() { return Iterator(Impl.HeadNode); } - NODISCARD FORCEINLINE ConstIterator End() const { return ConstIterator(Impl.HeadNode); } + NODISCARD FORCEINLINE FIterator Begin() { return FIterator(Impl.HeadNode->NextNode); } + NODISCARD FORCEINLINE FConstIterator Begin() const { return FConstIterator(Impl.HeadNode->NextNode); } + NODISCARD FORCEINLINE FIterator End() { return FIterator(Impl.HeadNode); } + NODISCARD FORCEINLINE FConstIterator End() const { return FConstIterator(Impl.HeadNode); } /** @return The reverse iterator to the first or end element. */ - NODISCARD FORCEINLINE ReverseIterator RBegin() { return ReverseIterator(End()); } - NODISCARD FORCEINLINE ConstReverseIterator RBegin() const { return ConstReverseIterator(End()); } - NODISCARD FORCEINLINE ReverseIterator REnd() { return ReverseIterator(Begin()); } - NODISCARD FORCEINLINE ConstReverseIterator REnd() const { return ConstReverseIterator(Begin()); } + NODISCARD FORCEINLINE FReverseIterator RBegin() { return FReverseIterator(End()); } + NODISCARD FORCEINLINE FConstReverseIterator RBegin() const { return FConstReverseIterator(End()); } + NODISCARD FORCEINLINE FReverseIterator REnd() { return FReverseIterator(Begin()); } + NODISCARD FORCEINLINE FConstReverseIterator REnd() const { return FConstReverseIterator(Begin()); } /** @return The number of elements in the container. */ NODISCARD FORCEINLINE size_t Num() const { return Impl.ListNum; } @@ -463,7 +463,7 @@ public: NODISCARD FORCEINLINE bool IsEmpty() const { return Num() == 0; } /** @return true if the iterator is valid, false otherwise. */ - NODISCARD FORCEINLINE bool IsValidIterator(ConstIterator Iter) const + NODISCARD FORCEINLINE bool IsValidIterator(FConstIterator Iter) const { FNode* Current = Impl.HeadNode; @@ -481,10 +481,10 @@ public: } /** @return The reference to the first or last element. */ - NODISCARD FORCEINLINE ElementType& Front() { return *Begin(); } - NODISCARD FORCEINLINE const ElementType& Front() const { return *Begin(); } - NODISCARD FORCEINLINE ElementType& Back() { return *(End() - 1); } - NODISCARD FORCEINLINE const ElementType& Back() const { return *(End() - 1); } + NODISCARD FORCEINLINE FElementType& Front() { return *Begin(); } + NODISCARD FORCEINLINE const FElementType& Front() const { return *Begin(); } + NODISCARD FORCEINLINE FElementType& Back() { return *(End() - 1); } + NODISCARD FORCEINLINE const FElementType& Back() const { return *(End() - 1); } /** Erases all elements from the container. After this call, Num() returns zero. */ void Reset() @@ -508,11 +508,11 @@ public: } /** Overloads the GetTypeHash algorithm for TList. */ - NODISCARD friend FORCEINLINE size_t GetTypeHash(const TList& A) requires (CHashable) + NODISCARD friend FORCEINLINE size_t GetTypeHash(const TList& A) requires (CHashable) { size_t Result = 0; - for (const ElementType& Element : A) + for (const FElementType& Element : A) { Result = HashCombine(Result, GetTypeHash(Element)); } @@ -535,7 +535,7 @@ private: { FNode* PrevNode; FNode* NextNode; - ElementType Value; + FElementType Value; FORCEINLINE FNode() = default; @@ -543,21 +543,21 @@ private: FORCEINLINE FNode(FInPlace, Ts&&... Args) : Value(Forward(Args)...) { } }; - static_assert(CMultipleAllocator); + static_assert(CMultipleAllocator); - ALLOCATOR_WRAPPER_BEGIN(AllocatorType, FNode, Impl) + ALLOCATOR_WRAPPER_BEGIN(FAllocatorType, FNode, Impl) { FNode* HeadNode; size_t ListNum; } - ALLOCATOR_WRAPPER_END(AllocatorType, FNode, Impl) + ALLOCATOR_WRAPPER_END(FAllocatorType, FNode, Impl) template class TIteratorImpl final { public: - using ElementType = TRemoveCV; + using FElementType = TRemoveCV; FORCEINLINE TIteratorImpl() = default; diff --git a/Redcraft.Utility/Source/Public/Containers/StaticArray.h b/Redcraft.Utility/Source/Public/Containers/StaticArray.h index 7b730ba..1fd36ce 100644 --- a/Redcraft.Utility/Source/Public/Containers/StaticArray.h +++ b/Redcraft.Utility/Source/Public/Containers/StaticArray.h @@ -25,22 +25,22 @@ private: public: - using ElementType = T; + using FElementType = T; - using Reference = T&; - using ConstReference = const T&; + using FReference = T&; + using FConstReference = const T&; - using Iterator = TIteratorImpl; - using ConstIterator = TIteratorImpl; + using FIterator = TIteratorImpl; + using FConstIterator = TIteratorImpl; - using ReverseIterator = TReverseIterator< Iterator>; - using ConstReverseIterator = TReverseIterator; + using FReverseIterator = TReverseIterator< FIterator>; + using FConstReverseIterator = TReverseIterator; - static_assert(CContiguousIterator< Iterator>); - static_assert(CContiguousIterator); + static_assert(CContiguousIterator< FIterator>); + static_assert(CContiguousIterator); /** Compares the contents of two arrays. */ - NODISCARD friend constexpr bool operator==(const TStaticArray& LHS, const TStaticArray& RHS) requires (CWeaklyEqualityComparable) + NODISCARD friend constexpr bool operator==(const TStaticArray& LHS, const TStaticArray& RHS) requires (CWeaklyEqualityComparable) { if (LHS.Num() != RHS.Num()) return false; @@ -53,7 +53,7 @@ public: } /** Compares the contents of 'LHS' and 'RHS' lexicographically. */ - NODISCARD friend constexpr auto operator<=>(const TStaticArray& LHS, const TStaticArray& RHS) requires (CSynthThreeWayComparable) + NODISCARD friend constexpr auto operator<=>(const TStaticArray& LHS, const TStaticArray& RHS) requires (CSynthThreeWayComparable) { const size_t NumToCompare = LHS.Num() < RHS.Num() ? LHS.Num() : RHS.Num(); @@ -66,20 +66,20 @@ public: } /** @return The pointer to the underlying element storage. */ - NODISCARD FORCEINLINE constexpr ElementType* GetData() { return _; } - NODISCARD FORCEINLINE constexpr const ElementType* GetData() const { return _; } + NODISCARD FORCEINLINE constexpr FElementType* GetData() { return _; } + NODISCARD FORCEINLINE constexpr const FElementType* GetData() const { return _; } /** @return The iterator to the first or end element. */ - NODISCARD FORCEINLINE constexpr Iterator Begin() { return Iterator(this, _); } - NODISCARD FORCEINLINE constexpr ConstIterator Begin() const { return ConstIterator(this, _); } - NODISCARD FORCEINLINE constexpr Iterator End() { return Iterator(this, _ + Num()); } - NODISCARD FORCEINLINE constexpr ConstIterator End() const { return ConstIterator(this, _ + Num()); } + NODISCARD FORCEINLINE constexpr FIterator Begin() { return FIterator(this, _); } + NODISCARD FORCEINLINE constexpr FConstIterator Begin() const { return FConstIterator(this, _); } + NODISCARD FORCEINLINE constexpr FIterator End() { return FIterator(this, _ + Num()); } + NODISCARD FORCEINLINE constexpr FConstIterator End() const { return FConstIterator(this, _ + Num()); } /** @return The reverse iterator to the first or end element. */ - NODISCARD FORCEINLINE constexpr ReverseIterator RBegin() { return ReverseIterator(End()); } - NODISCARD FORCEINLINE constexpr ConstReverseIterator RBegin() const { return ConstReverseIterator(End()); } - NODISCARD FORCEINLINE constexpr ReverseIterator REnd() { return ReverseIterator(Begin()); } - NODISCARD FORCEINLINE constexpr ConstReverseIterator REnd() const { return ConstReverseIterator(Begin()); } + NODISCARD FORCEINLINE constexpr FReverseIterator RBegin() { return FReverseIterator(End()); } + NODISCARD FORCEINLINE constexpr FConstReverseIterator RBegin() const { return FConstReverseIterator(End()); } + NODISCARD FORCEINLINE constexpr FReverseIterator REnd() { return FReverseIterator(Begin()); } + NODISCARD FORCEINLINE constexpr FConstReverseIterator REnd() const { return FConstReverseIterator(Begin()); } /** @return The number of elements in the container. */ NODISCARD FORCEINLINE constexpr size_t Num() const { return N; } @@ -88,24 +88,24 @@ public: NODISCARD FORCEINLINE constexpr bool IsEmpty() const { return Num() == 0; } /** @return true if the iterator is valid, false otherwise. */ - NODISCARD FORCEINLINE constexpr bool IsValidIterator(ConstIterator Iter) const { return Begin() <= Iter && Iter <= End(); } + NODISCARD FORCEINLINE constexpr bool IsValidIterator(FConstIterator Iter) const { return Begin() <= Iter && Iter <= End(); } /** @return The reference to the requested element. */ - NODISCARD FORCEINLINE constexpr ElementType& operator[](size_t Index) { checkf(Index < Num(), TEXT("Read access violation. Please check IsValidIterator().")); return _[Index]; } - NODISCARD FORCEINLINE constexpr const ElementType& operator[](size_t Index) const { checkf(Index < Num(), TEXT("Read access violation. Please check IsValidIterator().")); return _[Index]; } + NODISCARD FORCEINLINE constexpr FElementType& operator[](size_t Index) { checkf(Index < Num(), TEXT("Read access violation. Please check IsValidIterator().")); return _[Index]; } + NODISCARD FORCEINLINE constexpr const FElementType& operator[](size_t Index) const { checkf(Index < Num(), TEXT("Read access violation. Please check IsValidIterator().")); return _[Index]; } /** @return The reference to the first or last element. */ - NODISCARD FORCEINLINE constexpr ElementType& Front() { return *Begin(); } - NODISCARD FORCEINLINE constexpr const ElementType& Front() const { return *Begin(); } - NODISCARD FORCEINLINE constexpr ElementType& Back() { return *(End() - 1); } - NODISCARD FORCEINLINE constexpr const ElementType& Back() const { return *(End() - 1); } + NODISCARD FORCEINLINE constexpr FElementType& Front() { return *Begin(); } + NODISCARD FORCEINLINE constexpr const FElementType& Front() const { return *Begin(); } + NODISCARD FORCEINLINE constexpr FElementType& Back() { return *(End() - 1); } + NODISCARD FORCEINLINE constexpr const FElementType& Back() const { return *(End() - 1); } /** Overloads the GetTypeHash algorithm for TStaticArray. */ - NODISCARD friend FORCEINLINE constexpr size_t GetTypeHash(const TStaticArray& A) requires (CHashable) + NODISCARD friend FORCEINLINE constexpr size_t GetTypeHash(const TStaticArray& A) requires (CHashable) { size_t Result = 0; - for (ConstIterator Iter = A.Begin(); Iter != A.End(); ++Iter) + for (FConstIterator Iter = A.Begin(); Iter != A.End(); ++Iter) { Result = HashCombine(Result, GetTypeHash(*Iter)); } @@ -114,7 +114,7 @@ public: } /** Overloads the Swap algorithm for TStaticArray. */ - friend FORCEINLINE constexpr void Swap(TStaticArray& A, TStaticArray& B) requires (CSwappable) { Swap(A._, B._); } + friend FORCEINLINE constexpr void Swap(TStaticArray& A, TStaticArray& B) requires (CSwappable) { Swap(A._, B._); } ENABLE_RANGE_BASED_FOR_LOOP_SUPPORT @@ -127,7 +127,7 @@ private: { public: - using ElementType = TRemoveCV; + using FElementType = TRemoveCV; FORCEINLINE constexpr TIteratorImpl() = default; @@ -224,6 +224,8 @@ NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END +// ReSharper disable CppInconsistentNaming + NAMESPACE_STD_BEGIN // Support structure binding, should not be directly used. @@ -245,3 +247,5 @@ template FORCEINLINE constexpr decltype(aut NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END + +// ReSharper restore CppInconsistentNaming diff --git a/Redcraft.Utility/Source/Public/Containers/StaticBitset.h b/Redcraft.Utility/Source/Public/Containers/StaticBitset.h index 137eecf..884bee2 100644 --- a/Redcraft.Utility/Source/Public/Containers/StaticBitset.h +++ b/Redcraft.Utility/Source/Public/Containers/StaticBitset.h @@ -37,22 +37,22 @@ private: public: - using BlockType = InBlockType; - using ElementType = bool; + using FBlockType = InBlockType; + using FElementType = bool; - class Reference; - using ConstReference = bool; + class FReference; + using FConstReference = bool; - using Iterator = TIteratorImpl; - using ConstIterator = TIteratorImpl; + using FIterator = TIteratorImpl; + using FConstIterator = TIteratorImpl; - using ReverseIterator = TReverseIterator< Iterator>; - using ConstReverseIterator = TReverseIterator; + using FReverseIterator = TReverseIterator< FIterator>; + using FConstReverseIterator = TReverseIterator; - static_assert(CRandomAccessIterator< Iterator>); - static_assert(CRandomAccessIterator); + static_assert(CRandomAccessIterator< FIterator>); + static_assert(CRandomAccessIterator); - static constexpr size_t BlockWidth = sizeof(BlockType) * 8; + static constexpr size_t BlockWidth = sizeof(FBlockType) * 8; /** Default constructor. Constructs an empty bitset. */ FORCEINLINE constexpr TStaticBitset() = default; @@ -60,38 +60,38 @@ public: /** Constructs a bitset from an integer. */ constexpr TStaticBitset(uint64 InValue) { - static_assert(sizeof(BlockType) <= sizeof(uint64), "The block width of TStaticBitset is unexpected"); + static_assert(sizeof(FBlockType) <= sizeof(uint64), "The block width of TStaticBitset is unexpected"); - if constexpr (sizeof(BlockType) == sizeof(uint8)) + if constexpr (sizeof(FBlockType) == sizeof(uint8)) { - if constexpr (N > 0) Impl[0] = static_cast(InValue >> 0); - if constexpr (N > 8) Impl[1] = static_cast(InValue >> 8); - if constexpr (N > 16) Impl[2] = static_cast(InValue >> 16); - if constexpr (N > 24) Impl[3] = static_cast(InValue >> 24); - if constexpr (N > 32) Impl[4] = static_cast(InValue >> 32); - if constexpr (N > 40) Impl[5] = static_cast(InValue >> 40); - if constexpr (N > 48) Impl[6] = static_cast(InValue >> 48); - if constexpr (N > 56) Impl[7] = static_cast(InValue >> 56); + if constexpr (N > 0) Impl[0] = static_cast(InValue >> 0); + if constexpr (N > 8) Impl[1] = static_cast(InValue >> 8); + if constexpr (N > 16) Impl[2] = static_cast(InValue >> 16); + if constexpr (N > 24) Impl[3] = static_cast(InValue >> 24); + if constexpr (N > 32) Impl[4] = static_cast(InValue >> 32); + if constexpr (N > 40) Impl[5] = static_cast(InValue >> 40); + if constexpr (N > 48) Impl[6] = static_cast(InValue >> 48); + if constexpr (N > 56) Impl[7] = static_cast(InValue >> 56); } - else if constexpr (sizeof(BlockType) == sizeof(uint16)) + else if constexpr (sizeof(FBlockType) == sizeof(uint16)) { - if constexpr (N > 0) Impl[0] = static_cast(InValue >> 0); - if constexpr (N > 16) Impl[1] = static_cast(InValue >> 16); - if constexpr (N > 32) Impl[2] = static_cast(InValue >> 32); - if constexpr (N > 48) Impl[3] = static_cast(InValue >> 48); + if constexpr (N > 0) Impl[0] = static_cast(InValue >> 0); + if constexpr (N > 16) Impl[1] = static_cast(InValue >> 16); + if constexpr (N > 32) Impl[2] = static_cast(InValue >> 32); + if constexpr (N > 48) Impl[3] = static_cast(InValue >> 48); } - else if constexpr (sizeof(BlockType) == sizeof(uint32)) + else if constexpr (sizeof(FBlockType) == sizeof(uint32)) { - if constexpr (N > 0) Impl[0] = static_cast(InValue >> 0); - if constexpr (N > 32) Impl[1] = static_cast(InValue >> 32); + if constexpr (N > 0) Impl[0] = static_cast(InValue >> 0); + if constexpr (N > 32) Impl[1] = static_cast(InValue >> 32); } - else if constexpr (sizeof(BlockType) == sizeof(uint64)) + else if constexpr (sizeof(FBlockType) == sizeof(uint64)) { - if constexpr (N > 0) Impl[0] = static_cast(InValue >> 0); + if constexpr (N > 0) Impl[0] = static_cast(InValue >> 0); } else check_no_entry(); - constexpr size_t BlockInteger = sizeof(uint64) / sizeof(BlockType); + constexpr size_t BlockInteger = sizeof(uint64) / sizeof(FBlockType); if constexpr ((N + BlockWidth - 1) / BlockWidth <= BlockInteger) return; @@ -126,7 +126,7 @@ public: if (LHS.Impl[Index] != RHS.Impl[Index]) return false; } - const BlockType LastBlockBitmask = LHS.Num() % BlockWidth != 0 ? (1ull << LHS.Num() % BlockWidth) - 1 : -1; + const FBlockType LastBlockBitmask = LHS.Num() % BlockWidth != 0 ? (1ull << LHS.Num() % BlockWidth) - 1 : -1; return (LHS.Impl[LHS.NumBlocks() - 1] & LastBlockBitmask) == (RHS.Impl[LHS.NumBlocks() - 1] & LastBlockBitmask); } @@ -269,7 +269,7 @@ public: if (Impl[Index] != -1) return false; } - const BlockType LastBlockBitmask = Num() % BlockWidth != 0 ? (1ull << Num() % BlockWidth) - 1 : -1; + const FBlockType LastBlockBitmask = Num() % BlockWidth != 0 ? (1ull << Num() % BlockWidth) - 1 : -1; return (Impl[NumBlocks() - 1] | ~LastBlockBitmask) == -1; } @@ -284,7 +284,7 @@ public: if (Impl[Index] != 0) return true; } - const BlockType LastBlockBitmask = Num() % BlockWidth != 0 ? (1ull << Num() % BlockWidth) - 1 : -1; + const FBlockType LastBlockBitmask = Num() % BlockWidth != 0 ? (1ull << Num() % BlockWidth) - 1 : -1; return (Impl[NumBlocks() - 1] & LastBlockBitmask) != 0; } @@ -299,24 +299,24 @@ public: size_t Result = 0; - constexpr auto BlockCount = [](BlockType Block) constexpr + constexpr auto BlockCount = [](FBlockType Block) constexpr { - static_assert(sizeof(BlockType) <= sizeof(uint64), "The block width of TStaticBitset is unexpected"); + static_assert(sizeof(FBlockType) <= sizeof(uint64), "The block width of TStaticBitset is unexpected"); - if constexpr (sizeof(BlockType) == sizeof(uint8)) + if constexpr (sizeof(FBlockType) == sizeof(uint8)) { Block = (Block & 0x55ull) + ((Block >> 1) & 0x55ull); Block = (Block & 0x33ull) + ((Block >> 2) & 0x33ull); Block = (Block & 0x0Full) + ((Block >> 4) & 0x0Full); } - else if constexpr (sizeof(BlockType) == sizeof(uint16)) + else if constexpr (sizeof(FBlockType) == sizeof(uint16)) { Block = (Block & 0x5555ull) + ((Block >> 1) & 0x5555ull); Block = (Block & 0x3333ull) + ((Block >> 2) & 0x3333ull); Block = (Block & 0x0F0Full) + ((Block >> 4) & 0x0F0Full); Block = (Block & 0x00FFull) + ((Block >> 8) & 0x00FFull); } - else if constexpr (sizeof(BlockType) == sizeof(uint32)) + else if constexpr (sizeof(FBlockType) == sizeof(uint32)) { Block = (Block & 0x55555555ull) + ((Block >> 1) & 0x55555555ull); Block = (Block & 0x33333333ull) + ((Block >> 2) & 0x33333333ull); @@ -324,7 +324,7 @@ public: Block = (Block & 0x00FF00FFull) + ((Block >> 8) & 0x00FF00FFull); Block = (Block & 0x0000FFFFull) + ((Block >> 16) & 0x0000FFFFull); } - else if constexpr (sizeof(BlockType) == sizeof(uint64)) + else if constexpr (sizeof(FBlockType) == sizeof(uint64)) { Block = (Block & 0x5555555555555555ull) + ((Block >> 1) & 0x5555555555555555ull); Block = (Block & 0x3333333333333333ull) + ((Block >> 2) & 0x3333333333333333ull); @@ -343,7 +343,7 @@ public: Result += BlockCount(Impl[Index]); } - const BlockType LastBlockBitmask = Num() % BlockWidth != 0 ? (1ull << Num() % BlockWidth) - 1 : -1; + const FBlockType LastBlockBitmask = Num() % BlockWidth != 0 ? (1ull << Num() % BlockWidth) - 1 : -1; Result += BlockCount(Impl[NumBlocks() - 1] & LastBlockBitmask); @@ -355,7 +355,7 @@ public: { for (size_t Index = 0; Index != NumBlocks(); ++Index) { - Impl[Index] = static_cast(InValue ? -1 : 0); + Impl[Index] = static_cast(InValue ? -1 : 0); } return *this; @@ -387,20 +387,20 @@ public: { for (size_t Index = 64 / BlockWidth; Index < NumBlocks() - 1; ++Index) { - checkf(Impl.Pointer[Index] != 0, TEXT("The bitset can not be represented in uint64. Please check Num().")); + checkf(Impl[Index] != 0, TEXT("The bitset can not be represented in uint64. Please check Num().")); } - const BlockType LastBlockBitmask = Num() % BlockWidth != 0 ? (1ull << Num() % BlockWidth) - 1 : -1; - const BlockType LastBlock = Impl.Pointer[NumBlocks() - 1] & LastBlockBitmask; + const FBlockType LastBlockBitmask = Num() % BlockWidth != 0 ? (1ull << Num() % BlockWidth) - 1 : -1; + const FBlockType LastBlock = Impl[NumBlocks() - 1] & LastBlockBitmask; checkf(LastBlock != 0, TEXT("The bitset can not be represented in uint64. Please check Num().")); } uint64 Result = 0; - static_assert(sizeof(BlockType) <= sizeof(uint64), "The block width of TStaticBitset is unexpected"); + static_assert(sizeof(FBlockType) <= sizeof(uint64), "The block width of TStaticBitset is unexpected"); - if constexpr (sizeof(BlockType) == sizeof(uint8)) + if constexpr (sizeof(FBlockType) == sizeof(uint8)) { if constexpr (N > 0) Result |= static_cast(Impl[0]) << 0; if constexpr (N > 8) Result |= static_cast(Impl[1]) << 8; @@ -411,19 +411,19 @@ public: if constexpr (N > 48) Result |= static_cast(Impl[6]) << 48; if constexpr (N > 56) Result |= static_cast(Impl[7]) << 56; } - else if constexpr (sizeof(BlockType) == sizeof(uint16)) + else if constexpr (sizeof(FBlockType) == sizeof(uint16)) { if constexpr (N > 0) Result |= static_cast(Impl[0]) << 0; if constexpr (N > 16) Result |= static_cast(Impl[1]) << 16; if constexpr (N > 32) Result |= static_cast(Impl[2]) << 32; if constexpr (N > 48) Result |= static_cast(Impl[3]) << 48; } - else if constexpr (sizeof(BlockType) == sizeof(uint32)) + else if constexpr (sizeof(FBlockType) == sizeof(uint32)) { if constexpr (N > 0) Result |= static_cast(Impl[0]) << 0; if constexpr (N > 32) Result |= static_cast(Impl[1]) << 32; } - else if constexpr (sizeof(BlockType) == sizeof(uint64)) + else if constexpr (sizeof(FBlockType) == sizeof(uint64)) { if constexpr (N > 0) Result |= static_cast(Impl[0]) << 0; } @@ -435,20 +435,20 @@ public: } /** @return The pointer to the underlying element storage. */ - NODISCARD FORCEINLINE constexpr BlockType* GetData() { return Impl; } - NODISCARD FORCEINLINE constexpr const BlockType* GetData() const { return Impl; } + NODISCARD FORCEINLINE constexpr FBlockType* GetData() { return Impl; } + NODISCARD FORCEINLINE constexpr const FBlockType* GetData() const { return Impl; } /** @return The iterator to the first or end bit. */ - NODISCARD FORCEINLINE constexpr Iterator Begin() { return Iterator(this, Impl, 0); } - NODISCARD FORCEINLINE constexpr ConstIterator Begin() const { return ConstIterator(this, Impl, 0); } - NODISCARD FORCEINLINE constexpr Iterator End() { return Iterator(this, Impl, Num()); } - NODISCARD FORCEINLINE constexpr ConstIterator End() const { return ConstIterator(this, Impl, Num()); } + NODISCARD FORCEINLINE constexpr FIterator Begin() { return FIterator(this, Impl, 0); } + NODISCARD FORCEINLINE constexpr FConstIterator Begin() const { return FConstIterator(this, Impl, 0); } + NODISCARD FORCEINLINE constexpr FIterator End() { return FIterator(this, Impl, Num()); } + NODISCARD FORCEINLINE constexpr FConstIterator End() const { return FConstIterator(this, Impl, Num()); } /** @return The reverse iterator to the first or end bit. */ - NODISCARD FORCEINLINE constexpr ReverseIterator RBegin() { return ReverseIterator(End()); } - NODISCARD FORCEINLINE constexpr ConstReverseIterator RBegin() const { return ConstReverseIterator(End()); } - NODISCARD FORCEINLINE constexpr ReverseIterator REnd() { return ReverseIterator(Begin()); } - NODISCARD FORCEINLINE constexpr ConstReverseIterator REnd() const { return ConstReverseIterator(Begin()); } + NODISCARD FORCEINLINE constexpr FReverseIterator RBegin() { return FReverseIterator(End()); } + NODISCARD FORCEINLINE constexpr FConstReverseIterator RBegin() const { return FConstReverseIterator(End()); } + NODISCARD FORCEINLINE constexpr FReverseIterator REnd() { return FReverseIterator(Begin()); } + NODISCARD FORCEINLINE constexpr FConstReverseIterator REnd() const { return FConstReverseIterator(Begin()); } /** @return The number of bits in the bitset. */ NODISCARD FORCEINLINE constexpr size_t Num() const { return N; } @@ -460,17 +460,17 @@ public: NODISCARD FORCEINLINE constexpr bool IsEmpty() const { return Num() == 0; } /** @return true if the iterator is valid, false otherwise. */ - NODISCARD FORCEINLINE constexpr bool IsValidIterator(ConstIterator Iter) const { return Begin() <= Iter && Iter <= End(); } + NODISCARD FORCEINLINE constexpr bool IsValidIterator(FConstIterator Iter) const { return Begin() <= Iter && Iter <= End(); } /** @return The reference to the requested bit. */ - NODISCARD FORCEINLINE constexpr Reference operator[](size_t Index) { checkf(Index < Num(), TEXT("Read access violation. Please check IsValidIterator().")); return *(Begin() + Index); } - NODISCARD FORCEINLINE constexpr ConstReference operator[](size_t Index) const { checkf(Index < Num(), TEXT("Read access violation. Please check IsValidIterator().")); return *(Begin() + Index); } + NODISCARD FORCEINLINE constexpr FReference operator[](size_t Index) { checkf(Index < Num(), TEXT("Read access violation. Please check IsValidIterator().")); return *(Begin() + Index); } + NODISCARD FORCEINLINE constexpr FConstReference operator[](size_t Index) const { checkf(Index < Num(), TEXT("Read access violation. Please check IsValidIterator().")); return *(Begin() + Index); } /** @return The reference to the first or last bit. */ - NODISCARD FORCEINLINE constexpr Reference Front() { return *Begin(); } - NODISCARD FORCEINLINE constexpr ConstReference Front() const { return *Begin(); } - NODISCARD FORCEINLINE constexpr Reference Back() { return *(End() - 1); } - NODISCARD FORCEINLINE constexpr ConstReference Back() const { return *(End() - 1); } + NODISCARD FORCEINLINE constexpr FReference Front() { return *Begin(); } + NODISCARD FORCEINLINE constexpr FConstReference Front() const { return *Begin(); } + NODISCARD FORCEINLINE constexpr FReference Back() { return *(End() - 1); } + NODISCARD FORCEINLINE constexpr FConstReference Back() const { return *(End() - 1); } /** Overloads the GetTypeHash algorithm for TStaticBitset. */ NODISCARD friend FORCEINLINE constexpr size_t GetTypeHash(const TStaticBitset& A) @@ -484,7 +484,7 @@ public: Result = HashCombine(Result, GetTypeHash(A.Impl[Index])); } - const BlockType LastBlockBitmask = A.Num() % BlockWidth != 0 ? (1ull << A.Num() % BlockWidth) - 1 : -1; + const FBlockType LastBlockBitmask = A.Num() % BlockWidth != 0 ? (1ull << A.Num() % BlockWidth) - 1 : -1; return HashCombine(Result, GetTypeHash(A.Impl[A.NumBlocks() - 1] & LastBlockBitmask)); } @@ -496,21 +496,21 @@ public: private: - BlockType Impl[N != 0 ? (N + BlockWidth - 1) / BlockWidth : 1]; + FBlockType Impl[N != 0 ? (N + BlockWidth - 1) / BlockWidth : 1]; public: - class Reference final : private FSingleton + class FReference final : private FSingleton { public: - FORCEINLINE constexpr Reference& operator=(bool InValue) { Data = (Data & ~Mask) | (InValue ? Mask : 0); return *this; } + FORCEINLINE constexpr FReference& operator=(bool InValue) { Data = (Data & ~Mask) | (InValue ? Mask : 0); return *this; } - FORCEINLINE constexpr Reference& operator=(const Reference& InValue) { *this = static_cast(InValue); return *this; } + FORCEINLINE constexpr FReference& operator=(const FReference& InValue) { *this = static_cast(InValue); return *this; } - FORCEINLINE constexpr Reference& operator&=(bool InValue) { Data &= InValue ? -1 : ~Mask; return *this; } - FORCEINLINE constexpr Reference& operator|=(bool InValue) { Data |= InValue ? Mask : 0; return *this; } - FORCEINLINE constexpr Reference& operator^=(bool InValue) { *this = InValue ^ *this; return *this; } + FORCEINLINE constexpr FReference& operator&=(bool InValue) { Data &= InValue ? -1 : ~Mask; return *this; } + FORCEINLINE constexpr FReference& operator|=(bool InValue) { Data |= InValue ? Mask : 0; return *this; } + FORCEINLINE constexpr FReference& operator^=(bool InValue) { *this = InValue ^ *this; return *this; } FORCEINLINE constexpr bool operator~() const { return !*this; } @@ -518,14 +518,14 @@ public: private: - FORCEINLINE constexpr Reference(BlockType& InData, BlockType InMask) + FORCEINLINE constexpr FReference(FBlockType& InData, FBlockType InMask) : Data(InData), Mask(InMask) { } - BlockType& Data; - BlockType Mask; + FBlockType& Data; + FBlockType Mask; - friend Iterator; + friend FIterator; }; @@ -538,7 +538,7 @@ private: public: - using ElementType = bool; + using FElementType = bool; FORCEINLINE constexpr TIteratorImpl() = default; @@ -561,8 +561,8 @@ private: NODISCARD friend FORCEINLINE constexpr strong_ordering operator<=>(const TIteratorImpl& LHS, const TIteratorImpl& RHS) { check(LHS.Pointer == RHS.Pointer); return LHS.BitOffset <=> RHS.BitOffset; } - NODISCARD FORCEINLINE constexpr Reference operator*() const requires (!bConst) { CheckThis(true); return Reference(*(Pointer + BitOffset / BlockWidth), 1ull << BitOffset % BlockWidth); } - NODISCARD FORCEINLINE constexpr ConstReference operator*() const requires ( bConst) { CheckThis(true); return (*(Pointer + BitOffset / BlockWidth) & (1ull << BitOffset % BlockWidth)); } + NODISCARD FORCEINLINE constexpr FReference operator*() const requires (!bConst) { CheckThis(true); return FReference(*(Pointer + BitOffset / BlockWidth), 1ull << BitOffset % BlockWidth); } + NODISCARD FORCEINLINE constexpr FConstReference operator*() const requires ( bConst) { CheckThis(true); return (*(Pointer + BitOffset / BlockWidth) & (1ull << BitOffset % BlockWidth)); } NODISCARD FORCEINLINE constexpr auto operator[](ptrdiff Index) const { TIteratorImpl Temp = *this + Index; return *Temp; } @@ -588,17 +588,17 @@ private: const TStaticBitset* Owner = nullptr; # endif - using BlockPtr = TConditional; + using FBlockPtr = TConditional; - BlockPtr Pointer = nullptr; - size_t BitOffset = 0; + FBlockPtr Pointer = nullptr; + size_t BitOffset = 0; # if DO_CHECK - FORCEINLINE constexpr TIteratorImpl(const TStaticBitset* InContainer, BlockPtr InPointer, size_t Offset) + FORCEINLINE constexpr TIteratorImpl(const TStaticBitset* InContainer, FBlockPtr InPointer, size_t Offset) : Owner(InContainer), Pointer(InPointer), BitOffset(Offset) { } # else - FORCEINLINE constexpr TIteratorImpl(const TStaticBitset* InContainer, BlockPtr InPointer, size_t Offset) + FORCEINLINE constexpr TIteratorImpl(const TStaticBitset* InContainer, FBlockPtr InPointer, size_t Offset) : Pointer(InPointer), BitOffset(Offset) { } # endif diff --git a/Redcraft.Utility/Source/Public/Iterator/BidirectionalIterator.h b/Redcraft.Utility/Source/Public/Iterator/BidirectionalIterator.h index 1c08f52..b75ef52 100644 --- a/Redcraft.Utility/Source/Public/Iterator/BidirectionalIterator.h +++ b/Redcraft.Utility/Source/Public/Iterator/BidirectionalIterator.h @@ -33,7 +33,7 @@ struct IBidirectionalIterator /* : IForwardIterator */ { // ~Begin CForwardIterator. - using ElementType = TRemoveCVRef; + using FElementType = TRemoveCVRef; IBidirectionalIterator(); IBidirectionalIterator(const IBidirectionalIterator&); diff --git a/Redcraft.Utility/Source/Public/Iterator/ContiguousIterator.h b/Redcraft.Utility/Source/Public/Iterator/ContiguousIterator.h index 58b44bf..c155721 100644 --- a/Redcraft.Utility/Source/Public/Iterator/ContiguousIterator.h +++ b/Redcraft.Utility/Source/Public/Iterator/ContiguousIterator.h @@ -35,7 +35,7 @@ struct IContiguousIterator /* : IRandomAccessIterator */ { // ~Begin CRandomAccessIterator. - using ElementType = TRemoveCVRef; + using FElementType = TRemoveCVRef; IContiguousIterator(); IContiguousIterator(const IContiguousIterator&); diff --git a/Redcraft.Utility/Source/Public/Iterator/CountedIterator.h b/Redcraft.Utility/Source/Public/Iterator/CountedIterator.h index 7cfbc35..eeb12ad 100644 --- a/Redcraft.Utility/Source/Public/Iterator/CountedIterator.h +++ b/Redcraft.Utility/Source/Public/Iterator/CountedIterator.h @@ -18,8 +18,8 @@ NAMESPACE_MODULE_BEGIN(Utility) NAMESPACE_PRIVATE_BEGIN -template class TCountedIteratorImpl { }; -template class TCountedIteratorImpl { public: using ElementType = TIteratorElement; }; +template class TCountedIteratorImpl { }; +template class TCountedIteratorImpl { public: using FElementType = TIteratorElement; }; NAMESPACE_PRIVATE_END @@ -34,7 +34,7 @@ class TCountedIterator final : public NAMESPACE_PRIVATE::TCountedIteratorImpl { public: - using IteratorType = I; + using FIteratorType = I; # if DO_CHECK FORCEINLINE constexpr TCountedIterator() requires (CDefaultConstructible) : Length(1), MaxLength(0) { } @@ -48,7 +48,7 @@ public: FORCEINLINE constexpr TCountedIterator& operator=(TCountedIterator&&) = default; FORCEINLINE constexpr ~TCountedIterator() = default; - FORCEINLINE constexpr explicit TCountedIterator(IteratorType InValue, ptrdiff N) : Current(MoveTemp(InValue)) { check_code({ MaxLength = N; }); } + FORCEINLINE constexpr explicit TCountedIterator(FIteratorType InValue, ptrdiff N) : Current(MoveTemp(InValue)) { check_code({ MaxLength = N; }); } template requires (!CSameAs && CConstructibleFrom) FORCEINLINE constexpr explicit (!CConvertibleTo) TCountedIterator(const TCountedIterator& InValue) @@ -106,14 +106,14 @@ public: NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(const TCountedIterator& LHS, FDefaultSentinel) { LHS.CheckThis(); return -LHS.Num(); } NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(FDefaultSentinel, const TCountedIterator& RHS) { RHS.CheckThis(); return RHS.Num(); } - NODISCARD FORCEINLINE constexpr const IteratorType& GetBase() const& { CheckThis(); return Current; } - NODISCARD FORCEINLINE constexpr IteratorType GetBase() && { CheckThis(); return MoveTemp(Current); } - NODISCARD FORCEINLINE constexpr ptrdiff Num() const { CheckThis(); return Length; } + NODISCARD FORCEINLINE constexpr const FIteratorType& GetBase() const& { CheckThis(); return Current; } + NODISCARD FORCEINLINE constexpr FIteratorType GetBase() && { CheckThis(); return MoveTemp(Current); } + NODISCARD FORCEINLINE constexpr ptrdiff Num() const { CheckThis(); return Length; } private: - IteratorType Current; - ptrdiff Length; + FIteratorType Current; + ptrdiff Length; # if DO_CHECK ptrdiff MaxLength; diff --git a/Redcraft.Utility/Source/Public/Iterator/ForwardIterator.h b/Redcraft.Utility/Source/Public/Iterator/ForwardIterator.h index 0ea46a6..27233c5 100644 --- a/Redcraft.Utility/Source/Public/Iterator/ForwardIterator.h +++ b/Redcraft.Utility/Source/Public/Iterator/ForwardIterator.h @@ -24,7 +24,7 @@ struct IForwardIterator /* : IInputIterator, IIncrementable, ISentinelFor; + using FElementType = TRemoveCVRef; // ~End CInputIterator. diff --git a/Redcraft.Utility/Source/Public/Iterator/InsertIterator.h b/Redcraft.Utility/Source/Public/Iterator/InsertIterator.h index ddd651b..12c8657 100644 --- a/Redcraft.Utility/Source/Public/Iterator/InsertIterator.h +++ b/Redcraft.Utility/Source/Public/Iterator/InsertIterator.h @@ -140,7 +140,7 @@ NODISCARD FORCEINLINE constexpr auto MakeBackInserter(C& Container) /** Creates an iterator adapter inserted in the container. */ template -NODISCARD FORCEINLINE constexpr auto MakeInserter(C& Container, const typename C::ConstIterator& InIter) +NODISCARD FORCEINLINE constexpr auto MakeInserter(C& Container, const typename C::FConstIterator& InIter) { return NAMESPACE_PRIVATE::TInsertIterator([&Container, Iter = InIter](T&& A) mutable { Iter = Container.Insert(Iter, Forward(A)); }); } diff --git a/Redcraft.Utility/Source/Public/Iterator/MoveIterator.h b/Redcraft.Utility/Source/Public/Iterator/MoveIterator.h index b83d5c1..4a672e5 100644 --- a/Redcraft.Utility/Source/Public/Iterator/MoveIterator.h +++ b/Redcraft.Utility/Source/Public/Iterator/MoveIterator.h @@ -26,9 +26,9 @@ class TMoveIterator final { public: - using IteratorType = I; + using FIteratorType = I; - using ElementType = TIteratorElement; + using FElementType = TIteratorElement; FORCEINLINE constexpr TMoveIterator() requires (CDefaultConstructible) = default; @@ -38,7 +38,7 @@ public: FORCEINLINE constexpr TMoveIterator& operator=(TMoveIterator&&) = default; FORCEINLINE constexpr ~TMoveIterator() = default; - FORCEINLINE constexpr explicit TMoveIterator(IteratorType InValue) : Current(MoveTemp(InValue)) { } + FORCEINLINE constexpr explicit TMoveIterator(FIteratorType InValue) : Current(MoveTemp(InValue)) { } template requires (!CSameAs && CConstructibleFrom) FORCEINLINE constexpr explicit (!CConvertibleTo) TMoveIterator(const TReverseIterator& InValue) : Current(InValue.GetBase()) { } @@ -73,12 +73,12 @@ public: NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(const TMoveIterator& LHS, const TMoveIterator& RHS) requires (CSizedSentinelFor) { return LHS.GetBase() - RHS.GetBase(); } - NODISCARD FORCEINLINE constexpr const IteratorType& GetBase() const& { return Current; } - NODISCARD FORCEINLINE constexpr IteratorType GetBase() && { return MoveTemp(Current); } + NODISCARD FORCEINLINE constexpr const FIteratorType& GetBase() const& { return Current; } + NODISCARD FORCEINLINE constexpr FIteratorType GetBase() && { return MoveTemp(Current); } private: - IteratorType Current; + FIteratorType Current; }; @@ -100,7 +100,7 @@ class TMoveSentinel { public: - using SentinelType = S; + using FSentinelType = S; FORCEINLINE constexpr TMoveSentinel() = default; FORCEINLINE constexpr TMoveSentinel(const TMoveSentinel&) = default; @@ -109,7 +109,7 @@ public: FORCEINLINE constexpr TMoveSentinel& operator=(TMoveSentinel&&) = default; FORCEINLINE constexpr ~TMoveSentinel() = default; - FORCEINLINE constexpr explicit TMoveSentinel(SentinelType InValue) : Last(InValue) { } + FORCEINLINE constexpr explicit TMoveSentinel(FSentinelType InValue) : Last(InValue) { } template requires (!CSameAs && CConstructibleFrom) FORCEINLINE constexpr explicit (!CConvertibleTo) TMoveSentinel(const TMoveSentinel& InValue) : Last(InValue.Last) { } @@ -126,12 +126,12 @@ public: template requires (CSizedSentinelFor) NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(const TMoveIterator& Iter, const TMoveSentinel& Sentinel) { return Iter.GetBase() - Sentinel.GetBase(); } - NODISCARD FORCEINLINE constexpr const SentinelType& GetBase() const& { return Last; } - NODISCARD FORCEINLINE constexpr SentinelType GetBase() && { return MoveTemp(Last); } + NODISCARD FORCEINLINE constexpr const FSentinelType& GetBase() const& { return Last; } + NODISCARD FORCEINLINE constexpr FSentinelType GetBase() && { return MoveTemp(Last); } private: - SentinelType Last; + FSentinelType Last; }; diff --git a/Redcraft.Utility/Source/Public/Iterator/RandomAccessIterator.h b/Redcraft.Utility/Source/Public/Iterator/RandomAccessIterator.h index e51308e..c0e225b 100644 --- a/Redcraft.Utility/Source/Public/Iterator/RandomAccessIterator.h +++ b/Redcraft.Utility/Source/Public/Iterator/RandomAccessIterator.h @@ -37,7 +37,7 @@ struct IRandomAccessIterator /* : IBidirectionalIterator, ISizedSentinelFor; + using FElementType = TRemoveCVRef; // ~End CBidirectionalIterator. diff --git a/Redcraft.Utility/Source/Public/Iterator/ReverseIterator.h b/Redcraft.Utility/Source/Public/Iterator/ReverseIterator.h index 627e27b..41057cf 100644 --- a/Redcraft.Utility/Source/Public/Iterator/ReverseIterator.h +++ b/Redcraft.Utility/Source/Public/Iterator/ReverseIterator.h @@ -25,9 +25,9 @@ class TReverseIterator final { public: - using IteratorType = I; + using FIteratorType = I; - using ElementType = TIteratorElement; + using FElementType = TIteratorElement; FORCEINLINE constexpr TReverseIterator() = default; FORCEINLINE constexpr TReverseIterator(const TReverseIterator&) = default; @@ -36,7 +36,7 @@ public: FORCEINLINE constexpr TReverseIterator& operator=(TReverseIterator&&) = default; FORCEINLINE constexpr ~TReverseIterator() = default; - FORCEINLINE constexpr explicit TReverseIterator(IteratorType InValue) : Current(InValue) { } + FORCEINLINE constexpr explicit TReverseIterator(FIteratorType InValue) : Current(InValue) { } template requires (!CSameAs && CConstructibleFrom) FORCEINLINE constexpr explicit (!CConvertibleTo) TReverseIterator(const TReverseIterator& InValue) : Current(InValue.GetBase()) { } @@ -50,9 +50,9 @@ public: template requires (CThreeWayComparable) NODISCARD friend FORCEINLINE constexpr TCompareThreeWayResult operator<=>(const TReverseIterator& LHS, const TReverseIterator& RHS) { return RHS.GetBase() <=> LHS.GetBase(); } - NODISCARD FORCEINLINE constexpr TIteratorReference operator*() const { IteratorType Temp = GetBase(); return *--Temp; } + NODISCARD FORCEINLINE constexpr TIteratorReference operator*() const { FIteratorType Temp = GetBase(); return *--Temp; } - NODISCARD FORCEINLINE constexpr auto operator->() const requires (requires(const I Iter) { { ToAddress(Iter) } -> CSameAs>; }) { IteratorType Temp = GetBase(); return ToAddress(--Temp); } + NODISCARD FORCEINLINE constexpr auto operator->() const requires (requires(const I Iter) { { ToAddress(Iter) } -> CSameAs>; }) { FIteratorType Temp = GetBase(); return ToAddress(--Temp); } NODISCARD FORCEINLINE constexpr TIteratorReference operator[](ptrdiff Index) const requires (CRandomAccessIterator) { return GetBase()[-Index - 1]; } @@ -72,12 +72,12 @@ public: NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(const TReverseIterator& LHS, const TReverseIterator& RHS) requires (CSizedSentinelFor) { return RHS.GetBase() - LHS.GetBase(); } - NODISCARD FORCEINLINE constexpr const IteratorType& GetBase() const& { return Current; } - NODISCARD FORCEINLINE constexpr IteratorType GetBase() && { return MoveTemp(Current); } + NODISCARD FORCEINLINE constexpr const FIteratorType& GetBase() const& { return Current; } + NODISCARD FORCEINLINE constexpr FIteratorType GetBase() && { return MoveTemp(Current); } private: - IteratorType Current; + FIteratorType Current; }; diff --git a/Redcraft.Utility/Source/Public/Iterator/Utility.h b/Redcraft.Utility/Source/Public/Iterator/Utility.h index 3a949bd..b396226 100644 --- a/Redcraft.Utility/Source/Public/Iterator/Utility.h +++ b/Redcraft.Utility/Source/Public/Iterator/Utility.h @@ -12,17 +12,17 @@ NAMESPACE_PRIVATE_BEGIN template using TWithReference = T&; -template struct TIteratorElementImpl { }; -template struct TIteratorElementImpl { using Type = TRemoveCV; }; +template struct TIteratorElementImpl { }; +template struct TIteratorElementImpl { using FType = TRemoveCV; }; -template requires (requires { typename I::ElementType; }) -struct TIteratorElementImpl { using Type = typename I::ElementType; }; +template requires (requires { typename I::FElementType; }) +struct TIteratorElementImpl { using FType = typename I::FElementType; }; -template struct TIteratorPointerImpl { }; -template struct TIteratorPointerImpl { using Type = T*; }; +template struct TIteratorPointerImpl { }; +template struct TIteratorPointerImpl { using FType = T*; }; template requires (requires(I& Iter) { { Iter.operator->() } -> CPointer; }) -struct TIteratorPointerImpl { using Type = decltype(DeclVal().operator->()); }; +struct TIteratorPointerImpl { using FType = decltype(DeclVal().operator->()); }; NAMESPACE_PRIVATE_END @@ -33,10 +33,10 @@ template concept CDereferenceable = requires(T& A) { { *A } -> CReferenceable; }; template -using TIteratorElement = typename NAMESPACE_PRIVATE::TIteratorElementImpl>::Type; +using TIteratorElement = typename NAMESPACE_PRIVATE::TIteratorElementImpl>::FType; template -using TIteratorPointer = typename NAMESPACE_PRIVATE::TIteratorPointerImpl>::Type; +using TIteratorPointer = typename NAMESPACE_PRIVATE::TIteratorPointerImpl>::FType; template using TIteratorReference = decltype(*DeclVal()); @@ -75,13 +75,13 @@ struct IIndirectlyReadable * The element type of the indirectly readable type. * It must be a non-const, non-volatile and non-reference type and can be referenced, i.e. not a void type. */ - using ElementType = TRemoveCVRef; + using FElementType = TRemoveCVRef; /** * Indirectly read the element from the indirectly readable type. - * The return type may not be const ElementType&, this concept only requires that the return type - * and ElementType has some relationship, such as copy constructible to ElementType if the type is copyable. - * This means that returning a proxy class castable to ElementType is also valid. + * The return type may not be const FElementType&, this concept only requires that the return type + * and FElementType has some relationship, such as copy constructible to FElementType if the type is copyable. + * This means that returning a proxy class castable to FElementType is also valid. * If this is an iterator adaptor, use decltype(auto) to forward the return value. */ T operator*() const; @@ -227,7 +227,7 @@ struct IInputIterator /* : IInputOrOutputIterator, IIndirectlyReadable */ { // ~Begin CIndirectlyReadable. - using ElementType = TRemoveCVRef; + using FElementType = TRemoveCVRef; // ~End CIndirectlyReadable. diff --git a/Redcraft.Utility/Source/Public/Memory/Allocator.h b/Redcraft.Utility/Source/Public/Memory/Allocator.h index 4e9cc03..fabd1e4 100644 --- a/Redcraft.Utility/Source/Public/Memory/Allocator.h +++ b/Redcraft.Utility/Source/Public/Memory/Allocator.h @@ -17,7 +17,7 @@ concept CAllocatableObject = CObject && !CConst && !CVolatile && CDestr template concept CAllocator = !CSameAs && CAllocatableObject - && requires (typename A::template ForElementType& Allocator, T* InPtr, size_t Num, size_t NumAllocated) + && requires (typename A::template TForElementType& Allocator, T* InPtr, size_t Num, size_t NumAllocated) { { Allocator.Allocate(Num) } -> CSameAs; { Allocator.Deallocate(InPtr) } -> CSameAs; @@ -47,15 +47,15 @@ struct FAllocatorInterface static constexpr bool bSupportsMultipleAllocation = true; template - class ForElementType /*: private FSingleton*/ + class TForElementType /*: private FSingleton*/ { public: - ForElementType() = default; - ForElementType(const ForElementType&) = delete; - ForElementType(ForElementType&&) = delete; - ForElementType& operator=(const ForElementType&) = delete; - ForElementType& operator=(ForElementType&&) = delete; + TForElementType() = default; + TForElementType(const TForElementType&) = delete; + TForElementType(TForElementType&&) = delete; + TForElementType& operator=(const TForElementType&) = delete; + TForElementType& operator=(TForElementType&&) = delete; /** Allocates uninitialized storage. If 'InNum' is zero, return nullptr. */ NODISCARD FORCEINLINE T* Allocate(size_t InNum) = delete; @@ -110,7 +110,7 @@ struct FAllocatorInterface \ }; \ \ - PREPROCESSOR_JOIN(T, Name)> Name; + PREPROCESSOR_JOIN(T, Name)> Name; /** This is heap allocator that calls Memory::Malloc() directly for memory allocation. */ struct FHeapAllocator @@ -118,15 +118,15 @@ struct FHeapAllocator static constexpr bool bSupportsMultipleAllocation = true; template - class ForElementType /*: private FSingleton*/ + class TForElementType /*: private FSingleton*/ { public: - ForElementType() = default; - ForElementType(const ForElementType&) = delete; - ForElementType(ForElementType&&) = delete; - ForElementType& operator=(const ForElementType&) = delete; - ForElementType& operator=(ForElementType&&) = delete; + TForElementType() = default; + TForElementType(const TForElementType&) = delete; + TForElementType(TForElementType&&) = delete; + TForElementType& operator=(const TForElementType&) = delete; + TForElementType& operator=(TForElementType&&) = delete; NODISCARD FORCEINLINE T* Allocate(size_t InNum) { @@ -197,15 +197,15 @@ struct TInlineAllocator static constexpr bool bSupportsMultipleAllocation = false; template - class ForElementType /*: private FSingleton*/ + class TForElementType /*: private FSingleton*/ { public: - ForElementType() = default; - ForElementType(const ForElementType&) = delete; - ForElementType(ForElementType&&) = delete; - ForElementType& operator=(const ForElementType&) = delete; - ForElementType& operator=(ForElementType&&) = delete; + TForElementType() = default; + TForElementType(const TForElementType&) = delete; + TForElementType(TForElementType&&) = delete; + TForElementType& operator=(const TForElementType&) = delete; + TForElementType& operator=(TForElementType&&) = delete; NODISCARD FORCEINLINE T* Allocate(size_t InNum) { @@ -279,15 +279,15 @@ struct FNullAllocator static constexpr bool bSupportsMultipleAllocation = true; template - class ForElementType /*: private FSingleton*/ + class TForElementType /*: private FSingleton*/ { public: - ForElementType() = default; - ForElementType(const ForElementType&) = delete; - ForElementType(ForElementType&&) = delete; - ForElementType& operator=(const ForElementType&) = delete; - ForElementType& operator=(ForElementType&&) = delete; + TForElementType() = default; + TForElementType(const TForElementType&) = delete; + TForElementType(TForElementType&&) = delete; + TForElementType& operator=(const TForElementType&) = delete; + TForElementType& operator=(TForElementType&&) = delete; NODISCARD FORCEINLINE T* Allocate(size_t InNum) { check_no_entry(); return nullptr; } diff --git a/Redcraft.Utility/Source/Public/Memory/InOutPointer.h b/Redcraft.Utility/Source/Public/Memory/InOutPointer.h index 8c10836..b46fa8f 100644 --- a/Redcraft.Utility/Source/Public/Memory/InOutPointer.h +++ b/Redcraft.Utility/Source/Public/Memory/InOutPointer.h @@ -14,7 +14,7 @@ NAMESPACE_MODULE_BEGIN(Utility) NAMESPACE_PRIVATE_BEGIN template -using TRawPointer = TConditional, typename TPointerTraits>::ElementType*, RT>; +using TRawPointer = TConditional, typename TPointerTraits>::FElementType*, RT>; template class FInOutPtr final : private FSingleton @@ -57,7 +57,7 @@ NAMESPACE_PRIVATE_END template requires ((CVoid) || (CPointer) && (requires(NAMESPACE_PRIVATE::TRawPointer* RPtr, ST& SPtr, Ts&&... Args) { SPtr.Reset(RPtr, Forward(Args)...); }) || (CConstructibleFrom, Ts...> && CMoveAssignable) - && requires { typename TPointerTraits>::ElementType; }) + && requires { typename TPointerTraits>::FElementType; }) auto OutPtr(ST& InPtr, Ts&&... Args) { return NAMESPACE_PRIVATE::FInOutPtr, ST, Ts...>(InPtr, Forward(Args)...); @@ -67,7 +67,7 @@ template requires ((CVoid) && (requires(NAMESPACE_PRIVATE::TRawPointer* RPtr, ST& SPtr, Ts&&... Args) { SPtr.Reset(RPtr, Forward(Args)...); }) || (CConstructibleFrom, Ts...> && CMoveAssignable) && requires(ST& SPtr) { { SPtr.Release() } -> CConvertibleTo>; } - && requires { typename TPointerTraits>::ElementType; }) + && requires { typename TPointerTraits>::FElementType; }) auto InOutPtr(ST& InPtr, Ts&&... Args) { return NAMESPACE_PRIVATE::FInOutPtr, ST, Ts...>(InPtr, Forward(Args)...); diff --git a/Redcraft.Utility/Source/Public/Memory/PointerTraits.h b/Redcraft.Utility/Source/Public/Memory/PointerTraits.h index 433789f..548e26e 100644 --- a/Redcraft.Utility/Source/Public/Memory/PointerTraits.h +++ b/Redcraft.Utility/Source/Public/Memory/PointerTraits.h @@ -19,10 +19,10 @@ struct TPointerTraits { static constexpr bool bIsPointer = true; - using PointerType = T*; - using ElementType = T; + using FPointerType = T*; + using FElementType = T; - static FORCEINLINE constexpr ElementType* ToAddress(PointerType InPtr) + static FORCEINLINE constexpr FElementType* ToAddress(FPointerType InPtr) { return InPtr; } @@ -34,29 +34,29 @@ struct TPointerTraits { static constexpr bool bIsPointer = true; - using PointerType = T(*)[]; - using ElementType = T; + using FPointerType = T(*)[]; + using FElementType = T; - static FORCEINLINE constexpr ElementType* ToAddress(PointerType InPtr) + static FORCEINLINE constexpr FElementType* ToAddress(FPointerType InPtr) { return InPtr; } }; /** A specialization of TPointerTraits is provided for pointer-like type. */ -#define DEFINE_TPointerTraits(TPtr) \ - template \ - struct TPointerTraits> \ - { \ - static constexpr bool bIsPointer = true; \ - \ - using PointerType = TPtr; \ - using ElementType = TPtr::ElementType; \ - \ - static FORCEINLINE constexpr ElementType* ToAddress(const PointerType& InPtr) \ - { \ - return InPtr.Get(); \ - } \ +#define DEFINE_TPointerTraits(TPtr) \ + template \ + struct TPointerTraits> \ + { \ + static constexpr bool bIsPointer = true; \ + \ + using FPointerType = TPtr; \ + using FElementType = TPtr::FElementType; \ + \ + static FORCEINLINE constexpr FElementType* ToAddress(const FPointerType& InPtr) \ + { \ + return InPtr.Get(); \ + } \ }; NAMESPACE_MODULE_END(Utility) diff --git a/Redcraft.Utility/Source/Public/Memory/SharedPointer.h b/Redcraft.Utility/Source/Public/Memory/SharedPointer.h index 6b11ef0..b7eeba1 100644 --- a/Redcraft.Utility/Source/Public/Memory/SharedPointer.h +++ b/Redcraft.Utility/Source/Public/Memory/SharedPointer.h @@ -58,18 +58,18 @@ class alignas(Memory::ConstructiveInterference) FSharedController : private FSin { private: - using RefCounter = TAtomic; + using FRefCounter = TAtomic; // Ensure that counters are lock-free for performance. - static_assert(RefCounter::bIsAlwaysLockFree); + static_assert(FRefCounter::bIsAlwaysLockFree); // When this count is zero the object is destroyed. // This count is the number of TSharedRef and TSharedPtr. - RefCounter SharedReferenceCount; + FRefCounter SharedReferenceCount; // When this count is zero the controller is destroyed. // If SharedCounter is not zero this count is one more than the number of TWeakPtr. - RefCounter WeakReferenceCount; + FRefCounter WeakReferenceCount; public: @@ -86,7 +86,7 @@ public: virtual void DestroyThis() { delete this; } // Get shared reference count, no definite operation order. - FORCEINLINE RefCounter::ValueType GetSharedReferenceCount() + FORCEINLINE FRefCounter::FValueType GetSharedReferenceCount() { // Get the shared reference count as EMemoryOrder::Relaxed, // since this count is for reference only and has no guarantees, @@ -109,7 +109,7 @@ public: // if the shared reference count is zero return false. bool AddSharedReferenceIfUnexpired() { - RefCounter::ValueType OldSharedReferenceCount = GetSharedReferenceCount(); + FRefCounter::FValueType OldSharedReferenceCount = GetSharedReferenceCount(); // We need to make sure we don't increase the reference count from zero to one. while (true) @@ -131,7 +131,7 @@ public: // where EMemoryOrder::Release ensures that the side effects of all operations // on the shared reference count of all threads are visible to this thread, // preventing the shared reference count from actually going to zero. - RefCounter::ValueType OldSharedReferenceCount = SharedReferenceCount.FetchSub(1, EMemoryOrder::Release); + FRefCounter::FValueType OldSharedReferenceCount = SharedReferenceCount.FetchSub(1, EMemoryOrder::Release); // Make sure the shared reference count is not zero before. check(OldSharedReferenceCount != 0); @@ -166,7 +166,7 @@ public: { // The use of EMemoryOrder is the same as in ReleaseSharedReference(). - RefCounter::ValueType OldWeakReferenceCount = WeakReferenceCount.FetchSub(1, EMemoryOrder::Release); + FRefCounter::FValueType OldWeakReferenceCount = WeakReferenceCount.FetchSub(1, EMemoryOrder::Release); check(OldWeakReferenceCount != 0); @@ -407,12 +407,12 @@ struct FSharedHelper if constexpr (CTWeakPtr && CTWeakPtr) { if (&InValue == &This) UNLIKELY return This; - + if (This.Controller != nullptr) { This.Controller->ReleaseWeakReference(); } - + This.Pointer = Exchange(InValue.Pointer, nullptr); This.Controller = Exchange(InValue.Controller, nullptr); } @@ -522,7 +522,7 @@ protected: private: - using SharedFromThisType = TSharedFromThis; + using FSharedFromThisType = TSharedFromThis; // Here it is updated by the private constructor of TSharedRef or TSharedPtr. mutable TWeakPtr WeakThis; @@ -539,12 +539,12 @@ class TSharedRef final { private: - using Helper = NAMESPACE_PRIVATE::FSharedHelper; + using FHelper = NAMESPACE_PRIVATE::FSharedHelper; public: - using ElementType = T; - using WeakType = TWeakPtr; + using FElementType = T; + using FWeakType = TWeakPtr; /** TSharedRef cannot be initialized by nullptr. */ TSharedRef() = delete; @@ -580,7 +580,7 @@ public: Controller->AddSharedReference(); } - + /** * Aliasing constructor used to create a shared reference which shares its reference count with * another shared object, but pointing to a different object, typically a subobject. @@ -610,18 +610,18 @@ public: FORCEINLINE ~TSharedRef() { Controller->ReleaseSharedReference(); } /** Replaces the managed object with the one managed by 'InValue'. */ - FORCEINLINE TSharedRef& operator=(const TSharedRef& InValue) { return Helper::CopySharedReference(*this, InValue); } + FORCEINLINE TSharedRef& operator=(const TSharedRef& InValue) { return FHelper::CopySharedReference(*this, InValue); } /** Replaces the managed object with the one managed by 'InValue'. */ template requires (CConvertibleTo && !CArray) - FORCEINLINE TSharedRef& operator=(const TSharedRef& InValue) { return Helper::CopySharedReference(*this, InValue); } + FORCEINLINE TSharedRef& operator=(const TSharedRef& InValue) { return FHelper::CopySharedReference(*this, InValue); } /** Replaces the managed object with the one managed by 'InValue'. */ - FORCEINLINE TSharedRef& operator=(TSharedRef&& InValue) { return Helper::MoveSharedReference(*this, MoveTemp(InValue)); } + FORCEINLINE TSharedRef& operator=(TSharedRef&& InValue) { return FHelper::MoveSharedReference(*this, MoveTemp(InValue)); } /** Replaces the managed object with the one managed by 'InValue'. */ template requires (CConvertibleTo && !CArray) - FORCEINLINE TSharedRef& operator=(TSharedRef&& InValue) { return Helper::MoveSharedReference(*this, MoveTemp(InValue)); } + FORCEINLINE TSharedRef& operator=(TSharedRef&& InValue) { return FHelper::MoveSharedReference(*this, MoveTemp(InValue)); } /** Compares the pointer values of two TSharedRef. */ template requires (CEqualityComparable*>) @@ -732,15 +732,15 @@ private: { check(!((Pointer == nullptr) ^ (Controller == nullptr))); - if constexpr (CClass && !CVolatile && requires { typename T::SharedFromThisType; }) + if constexpr (CClass && !CVolatile && requires { typename T::FSharedFromThisType; }) { - using SharedFromThisType = T::SharedFromThisType; + using FSharedFromThisType = typename T::FSharedFromThisType; - if constexpr (CDerivedFrom) + if constexpr (CDerivedFrom) { if (Pointer != nullptr) { - const SharedFromThisType& SharedFromThis = *Pointer; + const FSharedFromThisType& SharedFromThis = *Pointer; checkf(!SharedFromThis.DoesSharedInstanceExist(), TEXT("This object is incorrectly managed by multiple TSharedRef or TSharedPtr.")); SharedFromThis.WeakThis = ConstCast>(*this); } @@ -762,12 +762,12 @@ class TSharedRef final { private: - using Helper = NAMESPACE_PRIVATE::FSharedHelper; + using FHelper = NAMESPACE_PRIVATE::FSharedHelper; public: - using ElementType = T; - using WeakType = TWeakPtr; + using FElementType = T; + using FWeakType = TWeakPtr; /** TSharedRef cannot be initialized by nullptr. */ TSharedRef() = delete; @@ -835,18 +835,18 @@ public: FORCEINLINE ~TSharedRef() { Controller->ReleaseSharedReference(); } /** Replaces the managed array with the one managed by 'InValue'. */ - FORCEINLINE TSharedRef& operator=(const TSharedRef& InValue) { return Helper::CopySharedReference(*this, InValue); } + FORCEINLINE TSharedRef& operator=(const TSharedRef& InValue) { return FHelper::CopySharedReference(*this, InValue); } /** Replaces the managed array with the one managed by 'InValue'. */ template requires (CConvertibleTo(*)[], T(*)[]> && CArray) - FORCEINLINE TSharedRef& operator=(const TSharedRef& InValue) { return Helper::CopySharedReference(*this, InValue); } + FORCEINLINE TSharedRef& operator=(const TSharedRef& InValue) { return FHelper::CopySharedReference(*this, InValue); } /** Replaces the managed array with the one managed by 'InValue'. */ - FORCEINLINE TSharedRef& operator=(TSharedRef&& InValue) { return Helper::MoveSharedReference(*this, MoveTemp(InValue)); } + FORCEINLINE TSharedRef& operator=(TSharedRef&& InValue) { return FHelper::MoveSharedReference(*this, MoveTemp(InValue)); } /** Replaces the managed array with the one managed by 'InValue'. */ template requires (CConvertibleTo(*)[], T(*)[]> && CArray) - FORCEINLINE TSharedRef& operator=(TSharedRef&& InValue) { return Helper::MoveSharedReference(*this, MoveTemp(InValue)); } + FORCEINLINE TSharedRef& operator=(TSharedRef&& InValue) { return FHelper::MoveSharedReference(*this, MoveTemp(InValue)); } /** Compares the pointer values of two TSharedRef. */ template requires (CEqualityComparable*>) @@ -972,13 +972,13 @@ class TSharedPtr final { private: - using Helper = NAMESPACE_PRIVATE::FSharedHelper; + using FHelper = NAMESPACE_PRIVATE::FSharedHelper; public: - using ElementType = T; - using WeakType = TWeakPtr; - + using FElementType = T; + using FWeakType = TWeakPtr; + /** Constructs an empty shared pointer. */ FORCEINLINE constexpr TSharedPtr() : Pointer(nullptr), Controller(nullptr) { } @@ -1073,22 +1073,22 @@ public: FORCEINLINE ~TSharedPtr() { if (Controller != nullptr) Controller->ReleaseSharedReference(); } /** Replaces the managed object with the one managed by 'InValue'. */ - FORCEINLINE TSharedPtr& operator=(const TSharedPtr& InValue) { return Helper::CopySharedReference(*this, InValue); } + FORCEINLINE TSharedPtr& operator=(const TSharedPtr& InValue) { return FHelper::CopySharedReference(*this, InValue); } /** Replaces the managed object with the one managed by 'InValue'. */ template requires (CConvertibleTo && !CArray) - FORCEINLINE TSharedPtr& operator=(const TSharedPtr& InValue) { return Helper::CopySharedReference(*this, InValue); } + FORCEINLINE TSharedPtr& operator=(const TSharedPtr& InValue) { return FHelper::CopySharedReference(*this, InValue); } /** Replaces the managed object with the one managed by 'InValue'. */ template requires (CConvertibleTo && !CArray) - FORCEINLINE TSharedPtr& operator=(const TSharedRef& InValue) { return Helper::CopySharedReference(*this, InValue); } + FORCEINLINE TSharedPtr& operator=(const TSharedRef& InValue) { return FHelper::CopySharedReference(*this, InValue); } /** Replaces the managed object with the one managed by 'InValue'. */ - FORCEINLINE TSharedPtr& operator=(TSharedPtr&& InValue) { return Helper::MoveSharedReference(*this, MoveTemp(InValue)); } + FORCEINLINE TSharedPtr& operator=(TSharedPtr&& InValue) { return FHelper::MoveSharedReference(*this, MoveTemp(InValue)); } /** Replaces the managed object with the one managed by 'InValue'. */ template requires (CConvertibleTo && !CArray) - FORCEINLINE TSharedPtr& operator=(TSharedPtr&& InValue) { return Helper::MoveSharedReference(*this, MoveTemp(InValue)); } + FORCEINLINE TSharedPtr& operator=(TSharedPtr&& InValue) { return FHelper::MoveSharedReference(*this, MoveTemp(InValue)); } /** Replaces the managed object with the one managed by 'InValue'. */ template requires (CConvertibleTo && !CArray && (CDestructible || CLValueReference)) @@ -1200,14 +1200,14 @@ private: T* Pointer; NAMESPACE_PRIVATE::FSharedController* Controller; - + FORCEINLINE TSharedPtr(const TWeakPtr& InValue) { const bool bIsUnexpired = InValue.Controller != nullptr && InValue.Controller->AddSharedReferenceIfUnexpired(); Pointer = bIsUnexpired ? InValue.Pointer : nullptr; Controller = bIsUnexpired ? InValue.Controller : nullptr; - + } FORCEINLINE TSharedPtr(T* InPtr, NAMESPACE_PRIVATE::FSharedController* InController) @@ -1215,15 +1215,15 @@ private: { check(!((Pointer == nullptr) ^ (Controller == nullptr))); - if constexpr (CClass && !CVolatile && requires { typename T::SharedFromThisType; }) + if constexpr (CClass && !CVolatile && requires { typename T::FSharedFromThisType; }) { - using SharedFromThisType = T::SharedFromThisType; + using FSharedFromThisType = typename T::FSharedFromThisType; - if constexpr (CDerivedFrom) + if constexpr (CDerivedFrom) { if (Pointer != nullptr) { - const SharedFromThisType& SharedFromThis = *Pointer; + const FSharedFromThisType& SharedFromThis = *Pointer; checkf(!SharedFromThis.DoesSharedInstanceExist(), TEXT("This object is incorrectly managed by multiple TSharedRef or TSharedPtr.")); SharedFromThis.WeakThis = ConstCast>(*this); } @@ -1245,12 +1245,12 @@ class TSharedPtr final { private: - using Helper = NAMESPACE_PRIVATE::FSharedHelper; + using FHelper = NAMESPACE_PRIVATE::FSharedHelper; public: - using ElementType = T; - using WeakType = TWeakPtr; + using FElementType = T; + using FWeakType = TWeakPtr; /** Constructs an empty shared pointer. */ FORCEINLINE constexpr TSharedPtr() : Pointer(nullptr), Controller(nullptr) { } @@ -1348,22 +1348,22 @@ public: FORCEINLINE ~TSharedPtr() { if (Controller != nullptr) Controller->ReleaseSharedReference(); } /** Replaces the managed array with the one managed by 'InValue'. */ - FORCEINLINE TSharedPtr& operator=(const TSharedPtr& InValue) { return Helper::CopySharedReference(*this, InValue); } + FORCEINLINE TSharedPtr& operator=(const TSharedPtr& InValue) { return FHelper::CopySharedReference(*this, InValue); } /** Replaces the managed array with the one managed by 'InValue'. */ template requires (CConvertibleTo(*)[], T(*)[]> && CArray) - FORCEINLINE TSharedPtr& operator=(const TSharedPtr& InValue) { return Helper::CopySharedReference(*this, InValue); } + FORCEINLINE TSharedPtr& operator=(const TSharedPtr& InValue) { return FHelper::CopySharedReference(*this, InValue); } /** Replaces the managed array with the one managed by 'InValue'. */ template requires (CConvertibleTo(*)[], T(*)[]> && CArray) - FORCEINLINE TSharedPtr& operator=(const TSharedRef& InValue) { return Helper::CopySharedReference(*this, InValue); } + FORCEINLINE TSharedPtr& operator=(const TSharedRef& InValue) { return FHelper::CopySharedReference(*this, InValue); } /** Replaces the managed array with the one managed by 'InValue'. */ - FORCEINLINE TSharedPtr& operator=(TSharedPtr&& InValue) { return Helper::MoveSharedReference(*this, MoveTemp(InValue)); } + FORCEINLINE TSharedPtr& operator=(TSharedPtr&& InValue) { return FHelper::MoveSharedReference(*this, MoveTemp(InValue)); } /** Replaces the managed array with the one managed by 'InValue'. */ template requires (CConvertibleTo(*)[], T(*)[]> && CArray) - FORCEINLINE TSharedPtr& operator=(TSharedPtr&& InValue) { return Helper::MoveSharedReference(*this, MoveTemp(InValue)); } + FORCEINLINE TSharedPtr& operator=(TSharedPtr&& InValue) { return FHelper::MoveSharedReference(*this, MoveTemp(InValue)); } /** Replaces the managed array with the one managed by 'InValue'. */ template requires (CConvertibleTo(*)[], T(*)[]> && CArray && (CDestructible || CLValueReference)) @@ -1482,7 +1482,7 @@ private: Pointer = bIsUnexpired ? InValue.Pointer : nullptr; Controller = bIsUnexpired ? InValue.Controller : nullptr; - + } FORCEINLINE TSharedPtr(T* InPtr, NAMESPACE_PRIVATE::FSharedController* InController) @@ -1505,11 +1505,11 @@ class TWeakPtr final { private: - using Helper = NAMESPACE_PRIVATE::FSharedHelper; + using FHelper = NAMESPACE_PRIVATE::FSharedHelper; public: - using ElementType = T; + using FElementType = T; /** Constructs an empty TWeakPtr */ FORCEINLINE constexpr TWeakPtr() : Pointer(nullptr), Controller(nullptr) { } @@ -1542,7 +1542,7 @@ public: /** Move constructors. Moves a TWeakPtr instance from 'InValue' into this. */ template requires (CConvertibleTo && !CArray) FORCEINLINE constexpr TWeakPtr(TWeakPtr&& InValue) : Pointer(Exchange(InValue.Pointer, nullptr)), Controller(Exchange(InValue.Controller, nullptr)) { } - + /** Constructs a weak pointer from a shared reference. */ template requires (CConvertibleTo && !CArray) FORCEINLINE constexpr TWeakPtr(const TSharedRef& InValue) : Pointer(InValue.Pointer), Controller(InValue.Controller) @@ -1564,26 +1564,26 @@ public: FORCEINLINE ~TWeakPtr() { if (Controller != nullptr) Controller->ReleaseWeakReference(); } /** Replaces the managed object with the one managed by 'InValue'. */ - FORCEINLINE TWeakPtr& operator=(const TWeakPtr& InValue) { return Helper::CopyWeakReference(*this, InValue); } + FORCEINLINE TWeakPtr& operator=(const TWeakPtr& InValue) { return FHelper::CopyWeakReference(*this, InValue); } /** Replaces the managed object with the one managed by 'InValue'. */ template requires (CConvertibleTo && !CArray) - FORCEINLINE TWeakPtr& operator=(const TWeakPtr& InValue) { return Helper::CopyWeakReference(*this, InValue); } + FORCEINLINE TWeakPtr& operator=(const TWeakPtr& InValue) { return FHelper::CopyWeakReference(*this, InValue); } /** Replaces the managed object with the one managed by 'InValue'. */ - FORCEINLINE TWeakPtr& operator=(TWeakPtr&& InValue) { return Helper::MoveWeakReference(*this, MoveTemp(InValue)); } + FORCEINLINE TWeakPtr& operator=(TWeakPtr&& InValue) { return FHelper::MoveWeakReference(*this, MoveTemp(InValue)); } /** Replaces the managed object with the one managed by 'InValue'. */ template requires (CConvertibleTo && !CArray) - FORCEINLINE TWeakPtr& operator=(TWeakPtr&& InValue) { return Helper::MoveWeakReference(*this, MoveTemp(InValue)); } + FORCEINLINE TWeakPtr& operator=(TWeakPtr&& InValue) { return FHelper::MoveWeakReference(*this, MoveTemp(InValue)); } /** Assignment operator sets this weak pointer from a shared reference. */ template requires (CConvertibleTo && !CArray) - FORCEINLINE TWeakPtr& operator=(const TSharedRef& InValue) { return Helper::CopyWeakReference(*this, InValue); } + FORCEINLINE TWeakPtr& operator=(const TSharedRef& InValue) { return FHelper::CopyWeakReference(*this, InValue); } /** Assignment operator sets this weak pointer from a shared pointer. */ template requires (CConvertibleTo && !CArray) - FORCEINLINE TWeakPtr& operator=(const TSharedPtr& InValue) { return Helper::CopyWeakReference(*this, InValue); } + FORCEINLINE TWeakPtr& operator=(const TSharedPtr& InValue) { return FHelper::CopyWeakReference(*this, InValue); } /** Effectively the same as calling Reset(). */ FORCEINLINE TWeakPtr& operator=(nullptr_t) { Reset(); return *this; } @@ -1639,11 +1639,11 @@ class TWeakPtr final { private: - using Helper = NAMESPACE_PRIVATE::FSharedHelper; + using FHelper = NAMESPACE_PRIVATE::FSharedHelper; public: - using ElementType = T; + using FElementType = T; /** Constructs an empty TWeakPtr */ FORCEINLINE constexpr TWeakPtr() : Pointer(nullptr), Controller(nullptr) { } @@ -1698,26 +1698,26 @@ public: FORCEINLINE ~TWeakPtr() { if (Controller != nullptr) Controller->ReleaseWeakReference(); } /** Replaces the managed array with the one managed by 'InValue'. */ - FORCEINLINE TWeakPtr& operator=(const TWeakPtr& InValue) { return Helper::CopyWeakReference(*this, InValue); } + FORCEINLINE TWeakPtr& operator=(const TWeakPtr& InValue) { return FHelper::CopyWeakReference(*this, InValue); } /** Replaces the managed array with the one managed by 'InValue'. */ template requires (CConvertibleTo(*)[], T(*)[]> && CArray) - FORCEINLINE TWeakPtr& operator=(const TWeakPtr& InValue) { return Helper::CopyWeakReference(*this, InValue); } + FORCEINLINE TWeakPtr& operator=(const TWeakPtr& InValue) { return FHelper::CopyWeakReference(*this, InValue); } /** Replaces the managed array with the one managed by 'InValue'. */ - FORCEINLINE TWeakPtr& operator=(TWeakPtr&& InValue) { return Helper::MoveWeakReference(*this, MoveTemp(InValue)); } + FORCEINLINE TWeakPtr& operator=(TWeakPtr&& InValue) { return FHelper::MoveWeakReference(*this, MoveTemp(InValue)); } /** Replaces the managed array with the one managed by 'InValue'. */ template requires (CConvertibleTo(*)[], T(*)[]> && CArray) - FORCEINLINE TWeakPtr& operator=(TWeakPtr&& InValue) { return Helper::MoveWeakReference(*this, MoveTemp(InValue)); } + FORCEINLINE TWeakPtr& operator=(TWeakPtr&& InValue) { return FHelper::MoveWeakReference(*this, MoveTemp(InValue)); } /** Assignment operator sets this weak pointer from a shared reference. */ template requires (CConvertibleTo(*)[], T(*)[]> && CArray) - FORCEINLINE TWeakPtr& operator=(const TSharedRef& InValue) { return Helper::CopyWeakReference(*this, InValue); } + FORCEINLINE TWeakPtr& operator=(const TSharedRef& InValue) { return FHelper::CopyWeakReference(*this, InValue); } /** Assignment operator sets this weak pointer from a shared pointer. */ template requires (CConvertibleTo(*)[], T(*)[]> && CArray) - FORCEINLINE TWeakPtr& operator=(const TSharedPtr& InValue) { return Helper::CopyWeakReference(*this, InValue); } + FORCEINLINE TWeakPtr& operator=(const TSharedPtr& InValue) { return FHelper::CopyWeakReference(*this, InValue); } /** Effectively the same as calling Reset(). */ FORCEINLINE TWeakPtr& operator=(nullptr_t) { Reset(); return *this; } diff --git a/Redcraft.Utility/Source/Public/Memory/UniquePointer.h b/Redcraft.Utility/Source/Public/Memory/UniquePointer.h index 52e163e..8149694 100644 --- a/Redcraft.Utility/Source/Public/Memory/UniquePointer.h +++ b/Redcraft.Utility/Source/Public/Memory/UniquePointer.h @@ -179,8 +179,8 @@ class TUniqueRef final : private FSingleton { public: - using ElementType = T; - using DeleterType = E; + using FElementType = T; + using FDeleterType = E; /** TUniqueRef cannot be initialized by nullptr. */ TUniqueRef() = delete; @@ -308,8 +308,8 @@ class TUniqueRef final : private FSingleton { public: - using ElementType = T; - using DeleterType = E; + using FElementType = T; + using FDeleterType = E; /** TUniqueRef cannot be initialized by nullptr. */ TUniqueRef() = delete; @@ -439,8 +439,8 @@ class TUniquePtr final : private FNoncopyable { public: - using ElementType = T; - using DeleterType = E; + using FElementType = T; + using FDeleterType = E; /** Constructs a TUniquePtr that owns nothing. Value-initializes the stored pointer and the stored deleter. */ FORCEINLINE constexpr TUniquePtr() requires(CDefaultConstructible && !CPointer) : Storage(nullptr) { } @@ -585,8 +585,8 @@ class TUniquePtr final : private FNoncopyable { public: - using ElementType = T; - using DeleterType = E; + using FElementType = T; + using FDeleterType = E; /** Constructs a TUniquePtr that owns nothing. Value-initializes the stored pointer and the stored deleter. */ FORCEINLINE constexpr TUniquePtr() requires(CDefaultConstructible && !CPointer) : Storage(nullptr) { } diff --git a/Redcraft.Utility/Source/Public/Miscellaneous/AssertionMacros.h b/Redcraft.Utility/Source/Public/Miscellaneous/AssertionMacros.h index 348ab9d..c8ac7ea 100644 --- a/Redcraft.Utility/Source/Public/Miscellaneous/AssertionMacros.h +++ b/Redcraft.Utility/Source/Public/Miscellaneous/AssertionMacros.h @@ -42,6 +42,8 @@ NAMESPACE_PRIVATE_END # define DO_CHECK 0 #endif +// ReSharper disable CppInconsistentNaming + #define always_check(InExpr) RS_CHECK_IMPL(InExpr) #define always_checkf(InExpr, InFormat, ...) RS_CHECK_F_IMPL(InExpr, InFormat, ##__VA_ARGS__) #define always_check_no_entry() always_checkf(false, "Enclosing block should never be called.") @@ -77,6 +79,8 @@ NAMESPACE_PRIVATE_END #endif +// ReSharper restore CppInconsistentNaming + NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h b/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h index e4b8c99..675729f 100644 --- a/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h +++ b/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h @@ -12,17 +12,21 @@ NAMESPACE_MODULE_BEGIN(Utility) // The result of the three-way comparison operator is the built-in type of the compiler, which is directly introduced here -typedef NAMESPACE_STD::partial_ordering partial_ordering; -typedef NAMESPACE_STD::weak_ordering weak_ordering; -typedef NAMESPACE_STD::strong_ordering strong_ordering; +// ReSharper disable CppInconsistentNaming + +using partial_ordering = NAMESPACE_STD::partial_ordering; +using weak_ordering = NAMESPACE_STD::weak_ordering; +using strong_ordering = NAMESPACE_STD::strong_ordering; + +// ReSharper restore CppInconsistentNaming NAMESPACE_PRIVATE_BEGIN -template struct TCommonComparisonCategoryBasic { }; -template<> struct TCommonComparisonCategoryBasic<0> { using Type = strong_ordering; }; -template<> struct TCommonComparisonCategoryBasic<2> { using Type = partial_ordering; }; -template<> struct TCommonComparisonCategoryBasic<4> { using Type = weak_ordering; }; -template<> struct TCommonComparisonCategoryBasic<6> { using Type = partial_ordering; }; +template struct TCommonComparisonCategoryBasic { }; +template<> struct TCommonComparisonCategoryBasic<0> { using FType = strong_ordering; }; +template<> struct TCommonComparisonCategoryBasic<2> { using FType = partial_ordering; }; +template<> struct TCommonComparisonCategoryBasic<4> { using FType = weak_ordering; }; +template<> struct TCommonComparisonCategoryBasic<6> { using FType = partial_ordering; }; template struct TCommonComparisonCategoryImpl @@ -32,13 +36,13 @@ struct TCommonComparisonCategoryImpl CSameAs ? 4u : CSameAs ? 2u : 1u ) - )> + )> { }; NAMESPACE_PRIVATE_END template -using TCommonComparisonCategory = typename NAMESPACE_PRIVATE::TCommonComparisonCategoryImpl::Type; +using TCommonComparisonCategory = typename NAMESPACE_PRIVATE::TCommonComparisonCategoryImpl::FType; template concept CThreeWayComparesAs = CSameAs, OrderingType>; diff --git a/Redcraft.Utility/Source/Public/Miscellaneous/ConstantIterator.h b/Redcraft.Utility/Source/Public/Miscellaneous/ConstantIterator.h index 66c35d4..a950971 100644 --- a/Redcraft.Utility/Source/Public/Miscellaneous/ConstantIterator.h +++ b/Redcraft.Utility/Source/Public/Miscellaneous/ConstantIterator.h @@ -17,7 +17,7 @@ class TConstantIterator final { public: - using ElementType = TRemoveCV; + using FElementType = TRemoveCV; FORCEINLINE constexpr TConstantIterator() = default; @@ -70,7 +70,7 @@ class TConstantIterator final { public: - using ElementType = TRemoveCV; + using FElementType = TRemoveCV; FORCEINLINE constexpr TConstantIterator() = default; @@ -115,14 +115,14 @@ class TCountedIterator> final { public: - using IteratorType = TConstantIterator; + using FIteratorType = TConstantIterator; - using ElementType = typename TConstantIterator::ElementType; + using FElementType = typename TConstantIterator::FElementType; # if DO_CHECK - FORCEINLINE constexpr TCountedIterator() requires (CDefaultConstructible) : Length(1), MaxLength(0) { } + FORCEINLINE constexpr TCountedIterator() requires (CDefaultConstructible) : Length(1), MaxLength(0) { } # else - FORCEINLINE constexpr TCountedIterator() requires (CDefaultConstructible) = default; + FORCEINLINE constexpr TCountedIterator() requires (CDefaultConstructible) = default; # endif FORCEINLINE constexpr TCountedIterator(const TCountedIterator&) = default; @@ -132,25 +132,25 @@ public: FORCEINLINE constexpr ~TCountedIterator() = default; - template requires (!CSameAs> && CConstructibleFrom) + template requires (!CSameAs> && CConstructibleFrom) FORCEINLINE constexpr explicit TCountedIterator(U&& InValue, ptrdiff N) : Current(Forward(InValue)), Length(N) { check_code({ MaxLength = N; }); } - template requires (!CSameAs && CConstructibleFrom) - FORCEINLINE constexpr explicit (!CConvertibleTo) TCountedIterator(const TCountedIterator& InValue) : Current(InValue.Current), Length(InValue.Num()) { check_code({ MaxLength = InValue.MaxLength; }); } + template requires (!CSameAs && CConstructibleFrom) + FORCEINLINE constexpr explicit (!CConvertibleTo) TCountedIterator(const TCountedIterator& InValue) : Current(InValue.Current), Length(InValue.Num()) { check_code({ MaxLength = InValue.MaxLength; }); } - template requires (!CSameAs && CConstructibleFrom) - FORCEINLINE constexpr explicit (!CConvertibleTo) TCountedIterator(TCountedIterator&& InValue) : Current(MoveTemp(InValue).Current), Length(InValue.Num()) { check_code({ MaxLength = InValue.MaxLength; }); } + template requires (!CSameAs && CConstructibleFrom) + FORCEINLINE constexpr explicit (!CConvertibleTo) TCountedIterator(TCountedIterator&& InValue) : Current(MoveTemp(InValue).Current), Length(InValue.Num()) { check_code({ MaxLength = InValue.MaxLength; }); } - template requires (!CSameAs && CConvertibleTo && CAssignableFrom) + template requires (!CSameAs && CConvertibleTo && CAssignableFrom) FORCEINLINE constexpr TCountedIterator& operator=(const TCountedIterator& InValue) { Current = InValue.Current; Length = InValue.Num(); check_code({ MaxLength = InValue.MaxLength; }); return *this; } - template requires (!CSameAs && CConvertibleTo && CAssignableFrom) + template requires (!CSameAs && CConvertibleTo && CAssignableFrom) FORCEINLINE constexpr TCountedIterator& operator=(TCountedIterator&& InValue) { Current = MoveTemp(InValue).Current; Length = InValue.Num(); check_code({ MaxLength = InValue.MaxLength; }); return *this; } - template J> + template J> NODISCARD friend FORCEINLINE constexpr bool operator==(const TCountedIterator& LHS, const TCountedIterator& RHS) { return LHS.Length == RHS.Length; } - template J> + template J> NODISCARD friend FORCEINLINE constexpr strong_ordering operator<=>(const TCountedIterator& LHS, const TCountedIterator& RHS) { return LHS.Length <=> RHS.Length; } NODISCARD FORCEINLINE constexpr bool operator==(FDefaultSentinel) const& { return Length == static_cast(0); } @@ -176,20 +176,20 @@ public: NODISCARD FORCEINLINE constexpr TCountedIterator operator-(ptrdiff Offset) const { TCountedIterator Temp = *this; Temp -= Offset; return Temp; } - template J> + template J> NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(const TCountedIterator& LHS, const TCountedIterator& RHS) { LHS.CheckThis(); RHS.CheckThis(); return LHS.Length - RHS.Length; } NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(const TCountedIterator& LHS, FDefaultSentinel) { LHS.CheckThis(); return -LHS.Num(); } NODISCARD friend FORCEINLINE constexpr ptrdiff operator-(FDefaultSentinel, const TCountedIterator& RHS) { RHS.CheckThis(); return RHS.Num(); } - NODISCARD FORCEINLINE constexpr const IteratorType& GetBase() const& { CheckThis(); return Current; } - NODISCARD FORCEINLINE constexpr IteratorType GetBase() && { CheckThis(); return MoveTemp(Current); } - NODISCARD FORCEINLINE constexpr ptrdiff Num() const { CheckThis(); return Length; } + NODISCARD FORCEINLINE constexpr const FIteratorType& GetBase() const& { CheckThis(); return Current; } + NODISCARD FORCEINLINE constexpr FIteratorType GetBase() && { CheckThis(); return MoveTemp(Current); } + NODISCARD FORCEINLINE constexpr ptrdiff Num() const { CheckThis(); return Length; } private: - IteratorType Current; - ptrdiff Length; + FIteratorType Current; + ptrdiff Length; # if DO_CHECK ptrdiff MaxLength; diff --git a/Redcraft.Utility/Source/Public/Miscellaneous/CoreMiscDefines.h b/Redcraft.Utility/Source/Public/Miscellaneous/CoreMiscDefines.h index 0f01718..a7c1d28 100644 --- a/Redcraft.Utility/Source/Public/Miscellaneous/CoreMiscDefines.h +++ b/Redcraft.Utility/Source/Public/Miscellaneous/CoreMiscDefines.h @@ -9,6 +9,8 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) +// ReSharper disable CppInconsistentNaming + #define NORETURN [[noreturn]] #define CARRIES_DEPENDENCY [[carries_dependency]] #define DEPRECATED(Message) [[deprecated(Message)]] @@ -42,6 +44,8 @@ using type_info = NAMESPACE_STD::type_info; template using initializer_list = NAMESPACE_STD::initializer_list; +// ReSharper restore CppInconsistentNaming + NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/Miscellaneous/Platform.h b/Redcraft.Utility/Source/Public/Miscellaneous/Platform.h index 57b3e0f..8d5e900 100644 --- a/Redcraft.Utility/Source/Public/Miscellaneous/Platform.h +++ b/Redcraft.Utility/Source/Public/Miscellaneous/Platform.h @@ -14,6 +14,8 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) +// ReSharper disable CppInconsistentNaming + // Platform information macro #ifndef PLATFORM_NAME @@ -527,6 +529,8 @@ NAMESPACE_PRIVATE_END #define U32TEXT(X) U32TEXT_PASTE(X) #define UNICODETEXT(X) U32TEXT_PASTE(X) +// ReSharper restore CppInconsistentNaming + NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/Numeric/Math.h b/Redcraft.Utility/Source/Public/Numeric/Math.h index cf9675c..0338225 100644 --- a/Redcraft.Utility/Source/Public/Numeric/Math.h +++ b/Redcraft.Utility/Source/Public/Numeric/Math.h @@ -444,83 +444,83 @@ RESOLVE_ARITHMETIC_AMBIGUITY_2_ARGS(CArithmetic, IsNearlyZero) template NODISCARD FORCEINLINE constexpr bool IsInfinity(T A) { - using Traits = NAMESPACE_PRIVATE::TFloatingTypeTraits; + using FTraits = NAMESPACE_PRIVATE::TFloatingTypeTraits; - auto IntegralValue = Math::BitCast(A); + auto IntegralValue = Math::BitCast(A); - return (IntegralValue & Traits::ExponentMask) == Traits::ExponentMask && (IntegralValue & Traits::MantissaMask) == 0; + return (IntegralValue & FTraits::ExponentMask) == FTraits::ExponentMask && (IntegralValue & FTraits::MantissaMask) == 0; } /** @return true if the given value is NaN, false otherwise. */ template NODISCARD FORCEINLINE constexpr bool IsNaN(T A) { - using Traits = NAMESPACE_PRIVATE::TFloatingTypeTraits; + using FTraits = NAMESPACE_PRIVATE::TFloatingTypeTraits; - auto IntegralValue = Math::BitCast(A); + auto IntegralValue = Math::BitCast(A); - return (IntegralValue & Traits::ExponentMask) == Traits::ExponentMask && (IntegralValue & Traits::MantissaMask) != 0; + return (IntegralValue & FTraits::ExponentMask) == FTraits::ExponentMask && (IntegralValue & FTraits::MantissaMask) != 0; } /** @return true if the given value is normal, false otherwise. */ template NODISCARD FORCEINLINE constexpr bool IsNormal(T A) { - using Traits = NAMESPACE_PRIVATE::TFloatingTypeTraits; + using FTraits = NAMESPACE_PRIVATE::TFloatingTypeTraits; - auto IntegralValue = Math::BitCast(A); + auto IntegralValue = Math::BitCast(A); - return (IntegralValue & Traits::ExponentMask) != 0 && (IntegralValue & Traits::ExponentMask) != Traits::ExponentMask; + return (IntegralValue & FTraits::ExponentMask) != 0 && (IntegralValue & FTraits::ExponentMask) != FTraits::ExponentMask; } /** @return true if the given value is subnormal, false otherwise. */ template NODISCARD FORCEINLINE constexpr bool IsDenorm(T A) { - using Traits = NAMESPACE_PRIVATE::TFloatingTypeTraits; + using FTraits = NAMESPACE_PRIVATE::TFloatingTypeTraits; - auto IntegralValue = Math::BitCast(A); + auto IntegralValue = Math::BitCast(A); - return (IntegralValue & Traits::ExponentMask) == 0 && (IntegralValue & Traits::MantissaMask) != 0; + return (IntegralValue & FTraits::ExponentMask) == 0 && (IntegralValue & FTraits::MantissaMask) != 0; } /** @return true if the given value is negative, even -0.0, false otherwise. */ template NODISCARD FORCEINLINE constexpr bool IsNegative(T A) { - using Traits = NAMESPACE_PRIVATE::TFloatingTypeTraits; + using FTraits = NAMESPACE_PRIVATE::TFloatingTypeTraits; - auto IntegralValue = Math::BitCast(A); + auto IntegralValue = Math::BitCast(A); - return (IntegralValue & Traits::SignMask) >> Traits::SignShift; + return (IntegralValue & FTraits::SignMask) >> FTraits::SignShift; } /** @return The exponent of the given value. */ template NODISCARD FORCEINLINE constexpr uint Exponent(T A) { - using Traits = NAMESPACE_PRIVATE::TFloatingTypeTraits; + using FTraits = NAMESPACE_PRIVATE::TFloatingTypeTraits; - auto IntegralValue = Math::BitCast(A); + auto IntegralValue = Math::BitCast(A); - return ((IntegralValue & Traits::ExponentMask) >> Traits::ExponentShift) - Traits::ExponentBias; + return ((IntegralValue & FTraits::ExponentMask) >> FTraits::ExponentShift) - FTraits::ExponentBias; } /** @return The NaN value with the given payload. */ template NODISCARD FORCEINLINE constexpr T NaN(U Payload) { - using Traits = NAMESPACE_PRIVATE::TFloatingTypeTraits; + using FTraits = NAMESPACE_PRIVATE::TFloatingTypeTraits; checkf(Payload != 0, TEXT("Illegal payload. It must not be zero.")); - checkf(Payload < (static_cast(1) << Traits::MantissaBits), TEXT("Illegal payload. It must be less than 2^MantissaBits.")); + checkf(Payload < (static_cast(1) << FTraits::MantissaBits), TEXT("Illegal payload. It must be less than 2^MantissaBits.")); if (Payload == 0) return TNumericLimits::QuietNaN(); - typename Traits::FIntegralT ValidPayload = Payload & Traits::MantissaMask; + typename FTraits::FIntegralT ValidPayload = Payload & FTraits::MantissaMask; - return Math::BitCast(ValidPayload | Traits::ExponentMask); + return Math::BitCast(ValidPayload | FTraits::ExponentMask); } /** @return The NaN value with the given payload. */ @@ -536,11 +536,11 @@ NODISCARD FORCEINLINE constexpr T NaN(U Payload) template NODISCARD FORCEINLINE constexpr auto NaNPayload(T A) { - using Traits = NAMESPACE_PRIVATE::TFloatingTypeTraits; + using FTraits = NAMESPACE_PRIVATE::TFloatingTypeTraits; - auto IntegralValue = Math::BitCast(A); + auto IntegralValue = Math::BitCast(A); - return IntegralValue & Traits::MantissaMask; + return IntegralValue & FTraits::MantissaMask; } /** @return The NaN payload of the given value. */ diff --git a/Redcraft.Utility/Source/Public/Range/Factory.h b/Redcraft.Utility/Source/Public/Range/Factory.h index 8810bfa..2e11ed6 100644 --- a/Redcraft.Utility/Source/Public/Range/Factory.h +++ b/Redcraft.Utility/Source/Public/Range/Factory.h @@ -19,18 +19,18 @@ class TEmptyView : public IBasicViewInterface> { public: - using ElementType = T; - using Reference = T&; - using Iterator = T*; - using Sentinel = T*; + using FElementType = T; + using FReference = T&; + using FIterator = T*; + using FSentinel = T*; FORCEINLINE constexpr TEmptyView() = default; - NODISCARD static FORCEINLINE constexpr Iterator Begin() { return nullptr; } - NODISCARD static FORCEINLINE constexpr Sentinel End() { return nullptr; } - NODISCARD static FORCEINLINE constexpr T* GetData() { return nullptr; } - NODISCARD static FORCEINLINE constexpr size_t Num() { return 0; } - NODISCARD static FORCEINLINE constexpr bool IsEmpty() { return true; } + NODISCARD static FORCEINLINE constexpr FIterator Begin() { return nullptr; } + NODISCARD static FORCEINLINE constexpr FSentinel End() { return nullptr; } + NODISCARD static FORCEINLINE constexpr T* GetData() { return nullptr; } + NODISCARD static FORCEINLINE constexpr size_t Num() { return 0; } + NODISCARD static FORCEINLINE constexpr bool IsEmpty() { return true; } }; @@ -52,16 +52,16 @@ class TSingleView : public IBasicViewInterface> { public: - using ElementType = T; + using FElementType = T; - using Reference = T&; - using ConstReference = const T&; + using FReference = T&; + using FConstReference = const T&; - using Iterator = T*; - using ConstIterator = const T*; + using FIterator = T*; + using FConstIterator = const T*; - using Sentinel = T*; - using ConstSentinel = const T*; + using FSentinel = T*; + using FConstSentinel = const T*; FORCEINLINE constexpr TSingleView() requires (CDefaultConstructible) = default; @@ -72,10 +72,10 @@ public: template requires (CConstructibleFrom) FORCEINLINE constexpr explicit TSingleView(FInPlace, Ts&&... Args) : Value(Forward(Args)...) { } - FORCEINLINE constexpr Iterator Begin() { return GetData(); } - FORCEINLINE constexpr ConstIterator Begin() const { return GetData(); } - FORCEINLINE constexpr Sentinel End() { return GetData() + 1; } - FORCEINLINE constexpr ConstSentinel End() const { return GetData() + 1; } + FORCEINLINE constexpr FIterator Begin() { return GetData(); } + FORCEINLINE constexpr FConstIterator Begin() const { return GetData(); } + FORCEINLINE constexpr FSentinel End() { return GetData() + 1; } + FORCEINLINE constexpr FConstSentinel End() const { return GetData() + 1; } NODISCARD FORCEINLINE constexpr T* GetData() { return AddressOf(Value); } NODISCARD FORCEINLINE constexpr const T* GetData() const { return AddressOf(Value); } @@ -108,13 +108,13 @@ private: public: - using ElementType = TRemoveCV; + using FElementType = TRemoveCV; - using Reference = W; + using FReference = W; - using Iterator = FIteratorImpl; + using FIterator = FIteratorImpl; - using Sentinel = TConditional, FIteratorImpl, FSentinelImpl>; + using FSentinel = TConditional, FIteratorImpl, FSentinelImpl>; FORCEINLINE constexpr TIotaView() requires (CDefaultConstructible) = default; @@ -122,13 +122,13 @@ public: FORCEINLINE constexpr explicit TIotaView(TIdentity InValue, TIdentity InLast) : First(InValue), Last(InLast) { } - FORCEINLINE constexpr explicit TIotaView(Iterator InFirst, Sentinel InLast) : First(InFirst.Value), Last(InLast.Value) { } + FORCEINLINE constexpr explicit TIotaView(FIterator InFirst, FSentinel InLast) : First(InFirst.Value), Last(InLast.Value) { } - FORCEINLINE constexpr explicit TIotaView(Iterator InFirst, FUnreachableSentinel) requires (CSameAs) : First(InFirst.Value) { } + FORCEINLINE constexpr explicit TIotaView(FIterator InFirst, FUnreachableSentinel) requires (CSameAs) : First(InFirst.Value) { } - NODISCARD FORCEINLINE constexpr Iterator Begin() const { return Iterator(First); } + NODISCARD FORCEINLINE constexpr FIterator Begin() const { return FIterator(First); } - NODISCARD FORCEINLINE constexpr Sentinel End() const { return Sentinel(Last); } + NODISCARD FORCEINLINE constexpr FSentinel End() const { return FSentinel(Last); } NODISCARD FORCEINLINE constexpr size_t Num() const requires ((CIntegral && CIntegral) || CSizedSentinelFor) { return Last - First; } @@ -143,13 +143,13 @@ private: { public: - using ElementType = TRemoveCV; + using FElementType = TRemoveCV; FORCEINLINE constexpr FIteratorImpl() requires (CDefaultConstructible) = default; NODISCARD friend FORCEINLINE constexpr bool operator==(const FIteratorImpl& LHS, const FIteratorImpl& RHS) requires (CEqualityComparable) { return LHS.Value == RHS.Value; } - NODISCARD FORCEINLINE constexpr Reference operator*() const { return Value; } + NODISCARD FORCEINLINE constexpr FReference operator*() const { return Value; } NODISCARD FORCEINLINE constexpr const W* operator->() const { return AddressOf(Value); } FORCEINLINE constexpr FIteratorImpl& operator++() { ++Value; return *this; } @@ -207,13 +207,13 @@ private: public: - using ElementType = W; + using FElementType = W; - using Reference = const W&; + using FReference = const W&; - using Iterator = FIteratorImpl; + using FIterator = FIteratorImpl; - using Sentinel = TConditional; + using FSentinel = TConditional; FORCEINLINE constexpr TRepeatView() requires (CDefaultConstructible) = default; @@ -228,16 +228,16 @@ public: template requires (CConstructibleFrom) FORCEINLINE constexpr explicit TRepeatView(FInPlace, Ts&&... Args, size_t InCount) : Value(Forward(Args)...), Count(InCount) { } - NODISCARD FORCEINLINE constexpr Iterator Begin() const { return Iterator(Value, 0); } + NODISCARD FORCEINLINE constexpr FIterator Begin() const { return FIterator(Value, 0); } - NODISCARD FORCEINLINE constexpr Sentinel End() const + NODISCARD FORCEINLINE constexpr FSentinel End() const { if constexpr (bIsUnreachable) { return UnreachableSentinel; } - else return Sentinel(Value, Count); + else return FSentinel(Value, Count); } NODISCARD FORCEINLINE constexpr size_t Num() const requires (!bIsUnreachable) { return Count; } @@ -254,7 +254,7 @@ private: { public: - using ElementType = W; + using FElementType = W; FORCEINLINE constexpr FIteratorImpl() requires (CDefaultConstructible) = default; @@ -262,10 +262,10 @@ private: NODISCARD friend FORCEINLINE constexpr strong_ordering operator<=>(const FIteratorImpl& LHS, const FIteratorImpl& RHS) { return LHS.Current <=> RHS.Current; } - NODISCARD FORCEINLINE constexpr Reference operator*() const { return *Ptr; } + NODISCARD FORCEINLINE constexpr FReference operator*() const { return *Ptr; } NODISCARD FORCEINLINE constexpr const W* operator->() const { return Ptr; } - NODISCARD FORCEINLINE constexpr Reference operator[](ptrdiff) const { return *Ptr; } + NODISCARD FORCEINLINE constexpr FReference operator[](ptrdiff) const { return *Ptr; } FORCEINLINE constexpr FIteratorImpl& operator++() { ++Current; return *this; } FORCEINLINE constexpr FIteratorImpl& operator--() { --Current; return *this; } diff --git a/Redcraft.Utility/Source/Public/Range/FilterView.h b/Redcraft.Utility/Source/Public/Range/FilterView.h index 247740d..c80e6b6 100644 --- a/Redcraft.Utility/Source/Public/Range/FilterView.h +++ b/Redcraft.Utility/Source/Public/Range/FilterView.h @@ -31,20 +31,20 @@ private: public: - using ElementType = TRangeElement; - using Reference = TRangeReference; + using FElementType = TRangeElement; + using FReference = TRangeReference; - using Iterator = FIteratorImpl; + using FIterator = FIteratorImpl; - using Sentinel = TConditional, FIteratorImpl, FSentinelImpl>; + using FSentinel = TConditional, FIteratorImpl, FSentinelImpl>; FORCEINLINE constexpr TFilterView() requires (CDefaultConstructible && CDefaultConstructible) = default; FORCEINLINE constexpr explicit TFilterView(V InBase, Pred InPredicate) : Base(MoveTemp(InBase)), Predicate(MoveTemp(InPredicate)) { } - NODISCARD FORCEINLINE constexpr Iterator Begin() + NODISCARD FORCEINLINE constexpr FIterator Begin() { - Iterator Iter(*this, Range::Begin(Base)); + FIterator Iter(*this, Range::Begin(Base)); do { @@ -61,7 +61,7 @@ public: return Iter; } - NODISCARD FORCEINLINE constexpr Sentinel End() { return Sentinel(*this, Range::End(Base)); } + NODISCARD FORCEINLINE constexpr FSentinel End() { return FSentinel(*this, Range::End(Base)); } NODISCARD FORCEINLINE constexpr V GetBase() const& requires (CCopyConstructible) { return Base; } NODISCARD FORCEINLINE constexpr V GetBase() && { return MoveTemp(Base); } @@ -79,7 +79,7 @@ private: public: - using ElementType = TIteratorElementType>; + using FElementType = TIteratorElementType>; FORCEINLINE constexpr FIteratorImpl() requires (CDefaultConstructible>) { } // Use '{ }' instead of '= default;' to avoid MSVC bug. diff --git a/Redcraft.Utility/Source/Public/Range/TransformView.h b/Redcraft.Utility/Source/Public/Range/TransformView.h index 5c3eb19..afa94ce 100644 --- a/Redcraft.Utility/Source/Public/Range/TransformView.h +++ b/Redcraft.Utility/Source/Public/Range/TransformView.h @@ -89,7 +89,7 @@ private: public: - using ElementType = TRemoveCVRef>>; + using FElementType = TRemoveCVRef>>; FORCEINLINE constexpr FIteratorImpl() requires (CDefaultConstructible>) = default; diff --git a/Redcraft.Utility/Source/Public/Range/View.h b/Redcraft.Utility/Source/Public/Range/View.h index 3fd9546..22b9ed5 100644 --- a/Redcraft.Utility/Source/Public/Range/View.h +++ b/Redcraft.Utility/Source/Public/Range/View.h @@ -100,7 +100,7 @@ class TRangeView : public IBasicViewInterface> { public: - using ElementType = TIteratorElementType; + using FElementType = TIteratorElementType; FORCEINLINE constexpr TRangeView() requires (CDefaultConstructible) = default; diff --git a/Redcraft.Utility/Source/Public/String/Char.h b/Redcraft.Utility/Source/Public/String/Char.h index 69d7a6d..73c9efe 100644 --- a/Redcraft.Utility/Source/Public/String/Char.h +++ b/Redcraft.Utility/Source/Public/String/Char.h @@ -68,31 +68,31 @@ static_assert(CUnsigned, "TChar assumes unicodechar is an unsigned template struct TChar { - using CharType = T; + using FCharType = T; /** The maximum number of code units required to represent a single character. if unknown, guess 1. */ static constexpr size_t MaxCodeUnitLength = - CSameAs ? MB_LEN_MAX : - CSameAs ? + CSameAs ? MB_LEN_MAX : + CSameAs ? PLATFORM_WINDOWS ? 2 : PLATFORM_LINUX ? 1 : 1 : - CSameAs ? 4 : - CSameAs ? 2 : - CSameAs ? 1 : 1; + CSameAs ? 4 : + CSameAs ? 2 : + CSameAs ? 1 : 1; /** Whether the character type is fixed-length. */ static constexpr bool bIsFixedLength = MaxCodeUnitLength == 1; - NODISCARD FORCEINLINE static constexpr bool IsValid(CharType InChar) + NODISCARD FORCEINLINE static constexpr bool IsValid(FCharType InChar) { - if constexpr (CSameAs) + if constexpr (CSameAs) { if ((InChar & 0b10000000) == 0b00000000) return true; return false; } - else if constexpr (CSameAs || CSameAs) + else if constexpr (CSameAs || CSameAs) { if (InChar >= 0xD800 && InChar <= 0xDBFF) return false; if (InChar >= 0xDC00 && InChar <= 0xDFFF) return false; @@ -101,30 +101,30 @@ struct TChar } // Windows uses UTF-16 encoding for wchar. - else if constexpr (PLATFORM_WINDOWS && (CSameAs)) + else if constexpr (PLATFORM_WINDOWS && (CSameAs)) { return TChar::IsValid(static_cast(InChar)); } // Linux uses UTF-32 encoding for wchar. - else if constexpr (PLATFORM_LINUX && (CSameAs)) + else if constexpr (PLATFORM_LINUX && (CSameAs)) { return TChar::IsValid(static_cast(InChar)); } - else static_assert(sizeof(CharType) == -1, "Unsupported character type"); + else static_assert(sizeof(FCharType) == -1, "Unsupported character type"); return false; } - NODISCARD FORCEINLINE static constexpr bool IsNonch(CharType InChar) + NODISCARD FORCEINLINE static constexpr bool IsNonch(FCharType InChar) { - if constexpr (CSameAs) + if constexpr (CSameAs) { return false; } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { if (InChar >= U16TEXT('\uFDD0') && InChar <= U16TEXT('\uFDEF')) return true; @@ -134,7 +134,7 @@ struct TChar return false; } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { if (InChar >= U32TEXT('\uFDD0') && InChar <= U32TEXT('\uFDEF')) return true; @@ -144,25 +144,25 @@ struct TChar } // Windows uses UTF-16 encoding for wchar. - else if constexpr (PLATFORM_WINDOWS && (CSameAs)) + else if constexpr (PLATFORM_WINDOWS && (CSameAs)) { return TChar::IsNonch(static_cast(InChar)); } // Linux uses UTF-32 encoding for wchar. - else if constexpr (PLATFORM_LINUX && (CSameAs)) + else if constexpr (PLATFORM_LINUX && (CSameAs)) { return TChar::IsNonch(static_cast(InChar)); } - else static_assert(sizeof(CharType) == -1, "Unsupported character type"); + else static_assert(sizeof(FCharType) == -1, "Unsupported character type"); return false; } - NODISCARD FORCEINLINE static constexpr bool IsASCII(CharType InChar = LITERAL(CharType, '\0')) + NODISCARD FORCEINLINE static constexpr bool IsASCII(FCharType InChar = LITERAL(FCharType, '\0')) { - if constexpr (CSameAs) + if constexpr (CSameAs) { constexpr bool ASCIICompatible = []() -> bool { @@ -188,7 +188,7 @@ struct TChar return ASCIICompatible && 0x00 <= InChar && InChar <= 0x7F; } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { constexpr bool ASCIICompatible = []() -> bool { @@ -214,19 +214,19 @@ struct TChar return ASCIICompatible && 0x00 <= InChar && InChar <= 0x7F; } - else if constexpr (CSameAs || CSameAs || CSameAs || CSameAs) + else if constexpr (CSameAs || CSameAs || CSameAs || CSameAs) { return InChar <= 0x7F; } - else static_assert(sizeof(CharType) == -1, "Unsupported character type"); + else static_assert(sizeof(FCharType) == -1, "Unsupported character type"); return false; } - NODISCARD FORCEINLINE static constexpr bool IsAlnum(CharType InChar) + NODISCARD FORCEINLINE static constexpr bool IsAlnum(FCharType InChar) { - if constexpr (CSameAs || CSameAs) + if constexpr (CSameAs || CSameAs) { NAMESPACE_STD::locale Loc(""); return NAMESPACE_STD::isalnum(InChar, Loc); @@ -237,15 +237,15 @@ struct TChar } } - NODISCARD FORCEINLINE static constexpr bool IsAlpha(CharType InChar) + NODISCARD FORCEINLINE static constexpr bool IsAlpha(FCharType InChar) { - if constexpr (CSameAs || CSameAs) + if constexpr (CSameAs || CSameAs) { NAMESPACE_STD::locale Loc(""); return NAMESPACE_STD::isalpha(InChar, Loc); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { /* * BASIC LATIN @@ -258,29 +258,29 @@ struct TChar return false; } - else if constexpr (CSameAs || CSameAs) + else if constexpr (CSameAs || CSameAs) { - checkf(InChar <= LITERAL(CharType, '\u007F'), TEXT("TChar::IsAlpha() only supports basic latin block.")); + checkf(InChar <= LITERAL(FCharType, '\u007F'), TEXT("TChar::IsAlpha() only supports basic latin block.")); - if (InChar > LITERAL(CharType, '\u007F')) return false; + if (InChar > LITERAL(FCharType, '\u007F')) return false; return TChar::IsAlpha(static_cast(InChar)); } - else static_assert(sizeof(CharType) == -1, "Unsupported character type"); + else static_assert(sizeof(FCharType) == -1, "Unsupported character type"); return false; } - NODISCARD FORCEINLINE static constexpr bool IsLower(CharType InChar) + NODISCARD FORCEINLINE static constexpr bool IsLower(FCharType InChar) { - if constexpr (CSameAs || CSameAs) + if constexpr (CSameAs || CSameAs) { NAMESPACE_STD::locale Loc(""); return NAMESPACE_STD::islower(InChar, Loc); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { /* * BASIC LATIN @@ -291,7 +291,7 @@ struct TChar return false; } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { checkf(InChar <= U16TEXT('\u007F'), TEXT("TChar::IsLower() only supports basic latin block.")); @@ -300,7 +300,7 @@ struct TChar return TChar::IsLower(static_cast(InChar)); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { checkf(InChar <= U32TEXT('\u007F'), TEXT("TChar::IsLower() only supports basic latin block.")); @@ -309,20 +309,20 @@ struct TChar return TChar::IsLower(static_cast(InChar)); } - else static_assert(sizeof(CharType) == -1, "Unsupported character type"); + else static_assert(sizeof(FCharType) == -1, "Unsupported character type"); return false; } - NODISCARD FORCEINLINE static constexpr bool IsUpper(CharType InChar) + NODISCARD FORCEINLINE static constexpr bool IsUpper(FCharType InChar) { - if constexpr (CSameAs || CSameAs) + if constexpr (CSameAs || CSameAs) { NAMESPACE_STD::locale Loc(""); return NAMESPACE_STD::isupper(InChar, Loc); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { /* * BASIC LATIN @@ -333,7 +333,7 @@ struct TChar return false; } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { checkf(InChar <= U16TEXT('\u007F'), TEXT("TChar::IsUpper() only supports basic latin block.")); @@ -342,7 +342,7 @@ struct TChar return TChar::IsUpper(static_cast(InChar)); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { checkf(InChar <= U32TEXT('\u007F'), TEXT("TChar::IsUpper() only supports basic latin block.")); @@ -351,20 +351,20 @@ struct TChar return TChar::IsUpper(static_cast(InChar)); } - else static_assert(sizeof(CharType) == -1, "Unsupported character type"); + else static_assert(sizeof(FCharType) == -1, "Unsupported character type"); return false; } - NODISCARD FORCEINLINE static constexpr bool IsDigit(CharType InChar) + NODISCARD FORCEINLINE static constexpr bool IsDigit(FCharType InChar) { static_assert(TChar::IsASCII()); /* ..; */ - return InChar >= LITERAL(CharType, '0') && InChar <= LITERAL(CharType, '9'); + return InChar >= LITERAL(FCharType, '0') && InChar <= LITERAL(FCharType, '9'); } - NODISCARD FORCEINLINE static constexpr bool IsDigit(CharType InChar, unsigned Base) + NODISCARD FORCEINLINE static constexpr bool IsDigit(FCharType InChar, unsigned Base) { checkf(Base >= 2 && Base <= 36, TEXT("Base must be in the range [2, 36].")); @@ -373,32 +373,32 @@ struct TChar bool bResult = false; /* ..; */ - bResult |= InChar >= LITERAL(CharType, '0') && InChar < LITERAL(CharType, '0') + static_cast(Base); + bResult |= InChar >= LITERAL(FCharType, '0') && InChar < LITERAL(FCharType, '0') + static_cast(Base); /* ..; */ - bResult |= InChar >= LITERAL(CharType, 'a') && InChar < LITERAL(CharType, 'a') + static_cast(Base) - 10; + bResult |= InChar >= LITERAL(FCharType, 'a') && InChar < LITERAL(FCharType, 'a') + static_cast(Base) - 10; /* ..; */ - bResult |= InChar >= LITERAL(CharType, 'A') && InChar < LITERAL(CharType, 'A') + static_cast(Base) - 10; + bResult |= InChar >= LITERAL(FCharType, 'A') && InChar < LITERAL(FCharType, 'A') + static_cast(Base) - 10; return bResult; } - NODISCARD FORCEINLINE static constexpr bool IsCntrl(CharType InChar) + NODISCARD FORCEINLINE static constexpr bool IsCntrl(FCharType InChar) { - if constexpr (CSameAs || CSameAs) + if constexpr (CSameAs || CSameAs) { NAMESPACE_STD::locale Loc(""); return NAMESPACE_STD::iscntrl(InChar, Loc); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { /* ..;; */ return (InChar >= U8TEXT('\u0000') && InChar <= U8TEXT('\u001F')) || InChar == U8TEXT('\u007F'); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { /* ..;..;;; */ return @@ -407,7 +407,7 @@ struct TChar (InChar == U16TEXT('\u2028') || InChar == U16TEXT('\u2029')); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { /* ..;..;;; */ return @@ -416,20 +416,20 @@ struct TChar (InChar == U32TEXT('\u2028') || InChar == U32TEXT('\u2029')); } - else static_assert(sizeof(CharType) == -1, "Unsupported character type"); + else static_assert(sizeof(FCharType) == -1, "Unsupported character type"); return false; } - NODISCARD FORCEINLINE static constexpr bool IsGraph(CharType InChar) + NODISCARD FORCEINLINE static constexpr bool IsGraph(FCharType InChar) { - if constexpr (CSameAs || CSameAs) + if constexpr (CSameAs || CSameAs) { NAMESPACE_STD::locale Loc(""); return NAMESPACE_STD::isgraph(InChar, Loc); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { /* * BASIC LATIN @@ -440,7 +440,7 @@ struct TChar return false; } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { checkf(InChar <= U16TEXT('\u007F'), TEXT("TChar::IsGraph() only supports basic latin block.")); @@ -449,7 +449,7 @@ struct TChar return TChar::IsGraph(static_cast(InChar)); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { checkf(InChar <= U32TEXT('\u007F'), TEXT("TChar::IsGraph() only supports basic latin block.")); @@ -458,20 +458,20 @@ struct TChar return TChar::IsGraph(static_cast(InChar)); } - else static_assert(sizeof(CharType) == -1, "Unsupported character type"); + else static_assert(sizeof(FCharType) == -1, "Unsupported character type"); return false; } - NODISCARD FORCEINLINE static constexpr bool IsSpace(CharType InChar) + NODISCARD FORCEINLINE static constexpr bool IsSpace(FCharType InChar) { - if constexpr (CSameAs || CSameAs) + if constexpr (CSameAs || CSameAs) { NAMESPACE_STD::locale Loc(""); return NAMESPACE_STD::isspace(InChar, Loc); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { /* * ISO/IEC 6429 @@ -488,7 +488,7 @@ struct TChar return false; } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { /* * ISO/IEC 6429 @@ -533,7 +533,7 @@ struct TChar return false; } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { /* * ISO/IEC 6429 @@ -578,26 +578,26 @@ struct TChar return false; } - else static_assert(sizeof(CharType) == -1, "Unsupported character type"); + else static_assert(sizeof(FCharType) == -1, "Unsupported character type"); return false; } - NODISCARD FORCEINLINE static constexpr bool IsBlank(CharType InChar) + NODISCARD FORCEINLINE static constexpr bool IsBlank(FCharType InChar) { - if constexpr (CSameAs || CSameAs) + if constexpr (CSameAs || CSameAs) { NAMESPACE_STD::locale Loc(""); return NAMESPACE_STD::isblank(InChar, Loc); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { /* ;; */ return InChar == U8TEXT('\u0009') || InChar == U8TEXT('\u0020'); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { /* ;;;;..;..;;; */ return @@ -608,7 +608,7 @@ struct TChar (InChar == U16TEXT('\u205F') || InChar == U16TEXT('\u3000')); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { /* ;;;;..;..;;; */ return @@ -619,20 +619,20 @@ struct TChar (InChar == U32TEXT('\u205F') || InChar == U32TEXT('\u3000')); } - else static_assert(sizeof(CharType) == -1, "Unsupported character type"); + else static_assert(sizeof(FCharType) == -1, "Unsupported character type"); return false; } - NODISCARD FORCEINLINE static constexpr bool IsPrint(CharType InChar) + NODISCARD FORCEINLINE static constexpr bool IsPrint(FCharType InChar) { - if constexpr (CSameAs || CSameAs) + if constexpr (CSameAs || CSameAs) { NAMESPACE_STD::locale Loc(""); return NAMESPACE_STD::isprint(InChar, Loc); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { /* * BASIC LATIN @@ -643,7 +643,7 @@ struct TChar return false; } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { checkf(InChar <= U16TEXT('\u007F'), TEXT("TChar::IsPrint() only supports basic latin block.")); @@ -652,7 +652,7 @@ struct TChar return TChar::IsPrint(static_cast(InChar)); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { checkf(InChar <= U32TEXT('\u007F'), TEXT("TChar::IsPrint() only supports basic latin block.")); @@ -661,20 +661,20 @@ struct TChar return TChar::IsPrint(static_cast(InChar)); } - else static_assert(sizeof(CharType) == -1, "Unsupported character type"); + else static_assert(sizeof(FCharType) == -1, "Unsupported character type"); return false; } - NODISCARD FORCEINLINE static constexpr bool IsPunct(CharType InChar) + NODISCARD FORCEINLINE static constexpr bool IsPunct(FCharType InChar) { - if constexpr (CSameAs || CSameAs) + if constexpr (CSameAs || CSameAs) { NAMESPACE_STD::locale Loc(""); return NAMESPACE_STD::ispunct(InChar, Loc); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { /* * BASIC LATIN @@ -689,7 +689,7 @@ struct TChar return false; } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { checkf(InChar <= U16TEXT('\u007F'), TEXT("TChar::IsPunct() only supports basic latin block.")); @@ -698,7 +698,7 @@ struct TChar return TChar::IsPunct(static_cast(InChar)); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { checkf(InChar <= U32TEXT('\u007F'), TEXT("TChar::IsPunct() only supports basic latin block.")); @@ -707,20 +707,20 @@ struct TChar return TChar::IsPunct(static_cast(InChar)); } - else static_assert(sizeof(CharType) == -1, "Unsupported character type"); + else static_assert(sizeof(FCharType) == -1, "Unsupported character type"); return false; } - NODISCARD FORCEINLINE static constexpr CharType ToLower(CharType InChar) + NODISCARD FORCEINLINE static constexpr FCharType ToLower(FCharType InChar) { - if constexpr (CSameAs || CSameAs) + if constexpr (CSameAs || CSameAs) { NAMESPACE_STD::locale Loc(""); - return static_cast(NAMESPACE_STD::tolower(InChar, Loc)); + return static_cast(NAMESPACE_STD::tolower(InChar, Loc)); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { /* * BASIC LATIN @@ -737,7 +737,7 @@ struct TChar return InChar; } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { checkf(InChar <= U16TEXT('\u007F'), TEXT("TChar::ToLower() only supports basic latin block.")); @@ -746,7 +746,7 @@ struct TChar return static_cast(TChar::ToLower(static_cast(InChar))); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { checkf(InChar <= U32TEXT('\u007F'), TEXT("TChar::ToLower() only supports basic latin block.")); @@ -755,20 +755,20 @@ struct TChar return static_cast(TChar::ToLower(static_cast(InChar))); } - else static_assert(sizeof(CharType) == -1, "Unsupported character type"); + else static_assert(sizeof(FCharType) == -1, "Unsupported character type"); return InChar; } - NODISCARD FORCEINLINE static constexpr CharType ToUpper(CharType InChar) + NODISCARD FORCEINLINE static constexpr FCharType ToUpper(FCharType InChar) { - if constexpr (CSameAs || CSameAs) + if constexpr (CSameAs || CSameAs) { NAMESPACE_STD::locale Loc(""); - return static_cast(NAMESPACE_STD::toupper(InChar, Loc)); + return static_cast(NAMESPACE_STD::toupper(InChar, Loc)); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { /* * BASIC LATIN @@ -785,7 +785,7 @@ struct TChar return InChar; } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { checkf(InChar <= U16TEXT('\u007F'), TEXT("TChar::ToUpper() only supports basic latin block.")); @@ -794,7 +794,7 @@ struct TChar return static_cast(TChar::ToUpper(static_cast(InChar))); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { checkf(InChar <= U32TEXT('\u007F'), TEXT("TChar::ToUpper() only supports basic latin block.")); @@ -803,12 +803,12 @@ struct TChar return static_cast(TChar::ToUpper(static_cast(InChar))); } - else static_assert(sizeof(CharType) == -1, "Unsupported character type"); + else static_assert(sizeof(FCharType) == -1, "Unsupported character type"); return InChar; } - NODISCARD FORCEINLINE static constexpr unsigned ToDigit(CharType InChar) + NODISCARD FORCEINLINE static constexpr unsigned ToDigit(FCharType InChar) { static_assert(TChar::IsASCII()); @@ -834,12 +834,12 @@ struct TChar static_assert(sizeof(DigitFromChar) == 256); - if constexpr (sizeof(CharType) > 1) if (InChar >> 8) return DigitFromChar[0]; + if constexpr (sizeof(FCharType) > 1) if (InChar >> 8) return DigitFromChar[0]; return DigitFromChar[InChar]; } - NODISCARD FORCEINLINE static constexpr unsigned ToDigit(CharType InChar, bool bLowercase) + NODISCARD FORCEINLINE static constexpr unsigned ToDigit(FCharType InChar, bool bLowercase) { static_assert(TChar::IsASCII()); @@ -867,7 +867,7 @@ struct TChar static_assert(sizeof(DigitFromChar) == 256); - if constexpr (sizeof(CharType) > 1) if (InChar >> 8) return DigitFromChar[0]; + if constexpr (sizeof(FCharType) > 1) if (InChar >> 8) return DigitFromChar[0]; return DigitFromChar[InChar]; } @@ -894,25 +894,25 @@ struct TChar static_assert(sizeof(DigitFromChar) == 256); - if constexpr (sizeof(CharType) > 1) if (InChar >> 8) return DigitFromChar[0]; + if constexpr (sizeof(FCharType) > 1) if (InChar >> 8) return DigitFromChar[0]; return DigitFromChar[InChar]; } - NODISCARD FORCEINLINE static constexpr CharType FromDigit(unsigned InDigit) + NODISCARD FORCEINLINE static constexpr FCharType FromDigit(unsigned InDigit) { checkf(InDigit < 36, TEXT("Digit must be in the range [0, 35].")); - return LITERAL(CharType, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")[InDigit]; + return LITERAL(FCharType, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")[InDigit]; } - NODISCARD FORCEINLINE static constexpr CharType FromDigit(unsigned InDigit, bool bLowercase) + NODISCARD FORCEINLINE static constexpr FCharType FromDigit(unsigned InDigit, bool bLowercase) { checkf(InDigit < 36, TEXT("Digit must be in the range [0, 35].")); - if (bLowercase) return LITERAL(CharType, "0123456789abcdefghijklmnopqrstuvwxyz")[InDigit]; + if (bLowercase) return LITERAL(FCharType, "0123456789abcdefghijklmnopqrstuvwxyz")[InDigit]; - return LITERAL(CharType, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")[InDigit]; + return LITERAL(FCharType, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")[InDigit]; } }; diff --git a/Redcraft.Utility/Source/Public/String/Conversion.h.inl b/Redcraft.Utility/Source/Public/String/Conversion.h.inl index c36d743..9a20026 100644 --- a/Redcraft.Utility/Source/Public/String/Conversion.h.inl +++ b/Redcraft.Utility/Source/Public/String/Conversion.h.inl @@ -264,6 +264,7 @@ struct TStringObjectFormatter { static bool Do(auto& Result, auto& Object, auto Param) { + // ReSharper disable once CppInconsistentNaming using U = TRemoveCVRef; if constexpr (!CConst>) @@ -1065,9 +1066,9 @@ struct TStringObjectFormatter } } - using UnsignedU = TMakeUnsigned; + using FUnsignedU = TMakeUnsigned; - UnsignedU Unsigned = static_cast(Object); + FUnsignedU Unsigned = static_cast(Object); bool bNegative = false; @@ -1077,11 +1078,11 @@ struct TStringObjectFormatter { bNegative = true; - Unsigned = static_cast(-Unsigned); + Unsigned = static_cast(-Unsigned); } } - constexpr size_t BufferSize = sizeof(UnsignedU) * 8 + 4; + constexpr size_t BufferSize = sizeof(FUnsignedU) * 8 + 4; T Buffer[BufferSize]; @@ -1111,8 +1112,8 @@ struct TStringObjectFormatter case 6: case 7: case 9: - case 10: do { *--Iter = static_cast('0' + Unsigned % Param.Base); Unsigned = static_cast(Unsigned / Param.Base); } while (Unsigned != 0); break; - default: do { *--Iter = TChar::FromDigit(Unsigned % Param.Base, bLowercase); Unsigned = static_cast(Unsigned / Param.Base); } while (Unsigned != 0); break; + case 10: do { *--Iter = static_cast('0' + Unsigned % Param.Base); Unsigned = static_cast(Unsigned / Param.Base); } while (Unsigned != 0); break; + default: do { *--Iter = TChar::FromDigit(Unsigned % Param.Base, bLowercase); Unsigned = static_cast(Unsigned / Param.Base); } while (Unsigned != 0); break; } } else @@ -1130,12 +1131,12 @@ struct TStringObjectFormatter case 6: case 7: case 9: - case 10: do { *--Iter = static_cast('0' + Unsigned % Param.Base); Unsigned = static_cast(Unsigned / Param.Base); } while (Unsigned != 0); break; - default: do { *--Iter = TChar::FromDigit(Unsigned % Param.Base); Unsigned = static_cast(Unsigned / Param.Base); } while (Unsigned != 0); break; + case 10: do { *--Iter = static_cast('0' + Unsigned % Param.Base); Unsigned = static_cast(Unsigned / Param.Base); } while (Unsigned != 0); break; + default: do { *--Iter = TChar::FromDigit(Unsigned % Param.Base); Unsigned = static_cast(Unsigned / Param.Base); } while (Unsigned != 0); break; } } } - else do { *--Iter = static_cast('0' + Unsigned % 10); Unsigned = static_cast(Unsigned / 10); } while (Unsigned != 0); + else do { *--Iter = static_cast('0' + Unsigned % 10); Unsigned = static_cast(Unsigned / 10); } while (Unsigned != 0); T* DigitBegin = Iter; @@ -1144,7 +1145,7 @@ struct TStringObjectFormatter { const size_t Padding = Param.Padding - (DigitEnd - DigitBegin); - if (Param.Padding < sizeof(UnsignedU) * 8) for (size_t Index = 0; Index != Padding; ++Index) *--Iter = LITERAL(T, '0'); + if (Param.Padding < sizeof(FUnsignedU) * 8) for (size_t Index = 0; Index != Padding; ++Index) *--Iter = LITERAL(T, '0'); } // Append the prefix to the buffer. @@ -1171,7 +1172,7 @@ struct TStringObjectFormatter { const size_t Padding = Param.Padding - (DigitEnd - DigitBegin); - if (Param.Padding > sizeof(UnsignedU) * 8) + if (Param.Padding > sizeof(FUnsignedU) * 8) { Result.Reserve(Result.Num() + (DigitBegin - Iter) + Param.Padding); @@ -1349,6 +1350,7 @@ struct TStringObjectParser { static bool Do(auto& View, auto& Object, auto Param) { + // ReSharper disable once CppInconsistentNaming using U = TRemoveCVRef; if constexpr (CConst>) @@ -2200,17 +2202,17 @@ struct TStringObjectParser return TChar::ToDigit(Char); }; - using UnsignedU = TMakeUnsigned; + using FUnsignedU = TMakeUnsigned; // The limit value that can be stored in an unsigned integer. - constexpr UnsignedU UnsignedMaximum = static_cast(-1); + constexpr FUnsignedU UnsignedMaximum = static_cast(-1); // The limit value that can be stored in a signed integer. constexpr U SignedMaximum = static_cast(UnsignedMaximum >> 1); constexpr U SignedMinimum = -static_cast(SignedMaximum) - 1; - UnsignedU LastValue = 0; - UnsignedU Unsigned = 0; + FUnsignedU LastValue = 0; + FUnsignedU Unsigned = 0; if (TrimmedView.IsEmpty()) return false; @@ -2223,7 +2225,7 @@ struct TStringObjectParser TrimmedView.RemovePrefix(1); - Unsigned = static_cast(Digit); + Unsigned = static_cast(Digit); while (!TrimmedView.IsEmpty()) { @@ -2235,7 +2237,7 @@ struct TStringObjectParser LastValue = Unsigned; - Unsigned = static_cast(LastValue * Base + Digit); + Unsigned = static_cast(LastValue * Base + Digit); if (Unsigned < LastValue) return false; } @@ -2245,11 +2247,11 @@ struct TStringObjectParser if constexpr (CSigned) { // Handle overflow. - if (!bNegative && Unsigned >= static_cast(SignedMaximum)) return false; - if ( bNegative && Unsigned >= static_cast(SignedMinimum)) return false; + if (!bNegative && Unsigned >= static_cast(SignedMaximum)) return false; + if ( bNegative && Unsigned >= static_cast(SignedMinimum)) return false; // Handle negative sign. - if (bNegative) Unsigned = static_cast(-Unsigned); + if (bNegative) Unsigned = static_cast(-Unsigned); } Object = static_cast(Unsigned); @@ -2705,14 +2707,14 @@ NAMESPACE_PRIVATE_END template Allocator> template -void TString::AppendFormat(TStringView Fmt, const Ts&... Args) +void TString::AppendFormat(TStringView Fmt, const Ts&... Args) { // The Unreal Engine says that the starting buffer size catches 99.97% of printf calls. constexpr size_t ReserveBufferSize = 512; TString> Result; - NAMESPACE_PRIVATE::TStringFormatOrParseHelper::Do(Result, Fmt, ForwardAsTuple(Args...)); + NAMESPACE_PRIVATE::TStringFormatOrParseHelper::Do(Result, Fmt, ForwardAsTuple(Args...)); Append(Result.Begin(), Result.End()); } @@ -2721,13 +2723,13 @@ template template size_t TStringView::ParseAndTrim(TStringView Fmt, Ts&... Args) { - return NAMESPACE_PRIVATE::TStringFormatOrParseHelper::Do(*this, Fmt, ForwardAsTuple(Args...)); + return NAMESPACE_PRIVATE::TStringFormatOrParseHelper::Do(*this, Fmt, ForwardAsTuple(Args...)); } template Allocator> void TString::AppendBool(bool Value) { - NAMESPACE_PRIVATE::TStringObjectFormatter::Do(*this, AsConst(Value), Invalid); + NAMESPACE_PRIVATE::TStringObjectFormatter::Do(*this, AsConst(Value), Invalid); } template Allocator> @@ -2738,13 +2740,13 @@ void TString::AppendInt(U Value, unsigned Base) struct { unsigned Base; } Param = { Base }; - NAMESPACE_PRIVATE::TStringObjectFormatter::Do(*this, AsConst(Value), Param); + NAMESPACE_PRIVATE::TStringObjectFormatter::Do(*this, AsConst(Value), Param); } template Allocator> template requires (!CConst && !CVolatile) void TString::AppendFloat(U Value) { - NAMESPACE_PRIVATE::TStringObjectFormatter::Do(*this, AsConst(Value), Invalid); + NAMESPACE_PRIVATE::TStringObjectFormatter::Do(*this, AsConst(Value), Invalid); } template Allocator> template requires (!CConst && !CVolatile) @@ -2752,7 +2754,7 @@ void TString::AppendFloat(U Value, bool bFixed, bool bScientific) { struct { bool bFixed; bool bScientific; } Param = { bFixed, bScientific }; - NAMESPACE_PRIVATE::TStringObjectFormatter::Do(*this, AsConst(Value), Param); + NAMESPACE_PRIVATE::TStringObjectFormatter::Do(*this, AsConst(Value), Param); } template Allocator> template requires (!CConst && !CVolatile) @@ -2760,7 +2762,7 @@ void TString::AppendFloat(U Value, bool bFixed, bool bScientific, { struct { bool bFixed; bool bScientific; unsigned Precision; } Param = { bFixed, bScientific, Precision }; - NAMESPACE_PRIVATE::TStringObjectFormatter::Do(*this, AsConst(Value), Param); + NAMESPACE_PRIVATE::TStringObjectFormatter::Do(*this, AsConst(Value), Param); } template @@ -2768,9 +2770,9 @@ constexpr bool TStringView::ToBoolAndTrim() { bool Value = false; - if (!NAMESPACE_PRIVATE::TStringObjectParser::Do(*this, Value, Invalid)) + if (!NAMESPACE_PRIVATE::TStringObjectParser::Do(*this, Value, Invalid)) { - if (int IntValue; NAMESPACE_PRIVATE::TStringObjectParser::Do(*this, IntValue, Invalid)) + if (int IntValue; NAMESPACE_PRIVATE::TStringObjectParser::Do(*this, IntValue, Invalid)) { Value = IntValue != 0; } @@ -2789,7 +2791,7 @@ constexpr U TStringView::ToIntAndTrim(unsigned Base) struct { unsigned Base; } Param = { Base }; - NAMESPACE_PRIVATE::TStringObjectParser::Do(*this, Value, Param); + NAMESPACE_PRIVATE::TStringObjectParser::Do(*this, Value, Param); return Value; } @@ -2802,7 +2804,7 @@ constexpr U TStringView::ToFloatAndTrim(bool bFixed, bool bScientific) struct { bool bFixed; bool bScientific; } Param = { bFixed, bScientific }; - NAMESPACE_PRIVATE::TStringObjectParser::Do(*this, Value, Param); + NAMESPACE_PRIVATE::TStringObjectParser::Do(*this, Value, Param); return Value; } diff --git a/Redcraft.Utility/Source/Public/String/String.h b/Redcraft.Utility/Source/Public/String/String.h index 6330833..7d0007a 100644 --- a/Redcraft.Utility/Source/Public/String/String.h +++ b/Redcraft.Utility/Source/Public/String/String.h @@ -35,33 +35,33 @@ class TString : public TArray { private: - using Super = TArray; + using FSuper = TArray; public: - using ElementType = typename Super::ElementType; - using AllocatorType = typename Super::AllocatorType; + using FElementType = typename FSuper::FElementType; + using FAllocatorType = typename FSuper::FAllocatorType; - using Reference = typename Super:: Reference; - using ConstReference = typename Super::ConstReference; + using FReference = typename FSuper:: FReference; + using FConstReference = typename FSuper::FConstReference; - using Iterator = typename Super:: Iterator; - using ConstIterator = typename Super::ConstIterator; + using FIterator = typename FSuper:: FIterator; + using FConstIterator = typename FSuper::FConstIterator; - using ReverseIterator = typename Super:: ReverseIterator; - using ConstReverseIterator = typename Super::ConstReverseIterator; + using FReverseIterator = typename FSuper:: FReverseIterator; + using FConstReverseIterator = typename FSuper::FConstReverseIterator; - static_assert(CContiguousIterator< Iterator>); - static_assert(CContiguousIterator); + static_assert(CContiguousIterator< FIterator>); + static_assert(CContiguousIterator); /** Default constructor. Constructs an empty string. */ FORCEINLINE TString() = default; /** Constructs the string with 'Count' copies of characters with 'InValue'. */ - FORCEINLINE TString(size_t Count, ElementType InChar) : Super(Count, InChar) { } + FORCEINLINE TString(size_t Count, FElementType InChar) : FSuper(Count, InChar) { } /** Constructs a string with the contents of the range ['InPtr', 'InPtr' + 'Count'). */ - FORCEINLINE TString(const ElementType* InPtr, size_t Count) : TString(TStringView(InPtr, Count)) + FORCEINLINE TString(const FElementType* InPtr, size_t Count) : TString(TStringView(InPtr, Count)) { checkf(InPtr != nullptr, TEXT("TString cannot be initialized by nullptr. Please check the pointer.")); } @@ -69,7 +69,7 @@ public: FORCEINLINE TString(nullptr_t, size_t) = delete; /** Constructs a string with the contents of the range ['InPtr', '\0'). */ - FORCEINLINE TString(const ElementType* InPtr) : TString(TStringView(InPtr)) + FORCEINLINE TString(const FElementType* InPtr) : TString(TStringView(InPtr)) { checkf(InPtr != nullptr, TEXT("TString cannot be initialized by nullptr. Please check the pointer.")); } @@ -77,11 +77,11 @@ public: FORCEINLINE TString(nullptr_t) = delete; /** Constructs the string with the contents of the 'View'. */ - FORCEINLINE TString(TStringView View) : TString(View.Begin(), View.End()) { } + FORCEINLINE TString(TStringView View) : TString(View.Begin(), View.End()) { } /** Constructs the string with the contents of the range ['First', 'Last'). */ - template S> requires (CConstructibleFrom>) - FORCEINLINE TString(I First, S Last) : Super(MoveTemp(First), MoveTemp(Last)) { } + template S> requires (CConstructibleFrom>) + FORCEINLINE TString(I First, S Last) : FSuper(MoveTemp(First), MoveTemp(Last)) { } /** Copy constructor. Constructs the string with the copy of the contents of 'InValue'. */ FORCEINLINE TString(const TString&) = default; @@ -90,7 +90,7 @@ public: FORCEINLINE TString(TString&&) = default; /** Constructs the string with the contents of the initializer list. */ - FORCEINLINE TString(initializer_list IL) : TString(Iteration::Begin(IL), Iteration::End(IL)) { } + FORCEINLINE TString(initializer_list IL) : TString(Iteration::Begin(IL), Iteration::End(IL)) { } /** Copy assignment operator. Replaces the contents with a copy of the contents of 'InValue'. */ FORCEINLINE TString& operator=(const TString&) = default; @@ -99,27 +99,27 @@ public: FORCEINLINE TString& operator=(TString&&) = default; /** Compares the contents of two strings. */ - NODISCARD friend FORCEINLINE bool operator==(const TString& LHS, const TString& RHS) { return TStringView(LHS) == TStringView(RHS); } + NODISCARD friend FORCEINLINE bool operator==(const TString& LHS, const TString& RHS) { return TStringView(LHS) == TStringView(RHS); } /** Compares the contents of a string and a character. */ - NODISCARD friend FORCEINLINE bool operator==(const TString& LHS, ElementType RHS) { return TStringView(LHS) == RHS; } - NODISCARD friend FORCEINLINE bool operator==(const TString& LHS, const ElementType* RHS) { return TStringView(LHS) == RHS; } - NODISCARD friend FORCEINLINE bool operator==( ElementType LHS, const TString& RHS) { return LHS == TStringView(RHS); } - NODISCARD friend FORCEINLINE bool operator==(const ElementType* LHS, const TString& RHS) { return LHS == TStringView(RHS); } + NODISCARD friend FORCEINLINE bool operator==(const TString& LHS, FElementType RHS) { return TStringView(LHS) == RHS; } + NODISCARD friend FORCEINLINE bool operator==(const TString& LHS, const FElementType* RHS) { return TStringView(LHS) == RHS; } + NODISCARD friend FORCEINLINE bool operator==( FElementType LHS, const TString& RHS) { return LHS == TStringView(RHS); } + NODISCARD friend FORCEINLINE bool operator==(const FElementType* LHS, const TString& RHS) { return LHS == TStringView(RHS); } /** Compares the contents of 'LHS' and 'RHS' lexicographically. */ - NODISCARD friend FORCEINLINE auto operator<=>(const TString& LHS, const TString& RHS) { return TStringView(LHS) <=> TStringView(RHS); } + NODISCARD friend FORCEINLINE auto operator<=>(const TString& LHS, const TString& RHS) { return TStringView(LHS) <=> TStringView(RHS); } /** Compares the contents of 'LHS' and 'RHS' lexicographically. */ - NODISCARD friend FORCEINLINE auto operator<=>(const TString& LHS, ElementType RHS) { return TStringView(LHS) <=> RHS; } - NODISCARD friend FORCEINLINE auto operator<=>(const TString& LHS, const ElementType* RHS) { return TStringView(LHS) <=> RHS; } - NODISCARD friend FORCEINLINE auto operator<=>( ElementType LHS, const TString& RHS) { return LHS <=> TStringView(RHS); } - NODISCARD friend FORCEINLINE auto operator<=>(const ElementType* LHS, const TString& RHS) { return LHS <=> TStringView(RHS); } + NODISCARD friend FORCEINLINE auto operator<=>(const TString& LHS, FElementType RHS) { return TStringView(LHS) <=> RHS; } + NODISCARD friend FORCEINLINE auto operator<=>(const TString& LHS, const FElementType* RHS) { return TStringView(LHS) <=> RHS; } + NODISCARD friend FORCEINLINE auto operator<=>( FElementType LHS, const TString& RHS) { return LHS <=> TStringView(RHS); } + NODISCARD friend FORCEINLINE auto operator<=>(const FElementType* LHS, const TString& RHS) { return LHS <=> TStringView(RHS); } public: /** Inserts 'InValue' before 'Index' in the string. */ - FORCEINLINE Iterator Insert(size_t Index, ElementType InValue) + FORCEINLINE FIterator Insert(size_t Index, FElementType InValue) { checkf(Index <= this->Num(), TEXT("Illegal index. Please check Index <= Num().")); @@ -127,15 +127,15 @@ public: } /** Inserts 'InValue' before 'Iter' in the string. */ - FORCEINLINE Iterator Insert(ConstIterator Iter, ElementType InValue) + FORCEINLINE FIterator Insert(FConstIterator Iter, FElementType InValue) { checkf(this->IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator().")); - return Super::Insert(Iter, InValue); + return FSuper::Insert(Iter, InValue); } /** Inserts 'Count' copies of the 'InValue' before 'Index' in the string. */ - FORCEINLINE Iterator Insert(size_t Index, size_t Count, ElementType InValue) + FORCEINLINE FIterator Insert(size_t Index, size_t Count, FElementType InValue) { checkf(Index <= this->Num(), TEXT("Illegal index. Please check Index <= Num().")); @@ -143,15 +143,15 @@ public: } /** Inserts 'Count' copies of the 'InValue' before 'Iter' in the string. */ - FORCEINLINE Iterator Insert(ConstIterator Iter, size_t Count, ElementType InValue) + FORCEINLINE FIterator Insert(FConstIterator Iter, size_t Count, FElementType InValue) { checkf(this->IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator().")); - return Super::Insert(Iter, Count, InValue); + return FSuper::Insert(Iter, Count, InValue); } /** Inserts characters from the 'View' before 'Index' in the string. */ - FORCEINLINE Iterator Insert(size_t Index, TStringView View) + FORCEINLINE FIterator Insert(size_t Index, TStringView View) { checkf(Index <= this->Num(), TEXT("Illegal index. Please check Index <= Num().")); @@ -159,7 +159,7 @@ public: } /** Inserts characters from the 'View' before 'Iter' in the string. */ - FORCEINLINE Iterator Insert(ConstIterator Iter, TStringView View) + FORCEINLINE FIterator Insert(FConstIterator Iter, TStringView View) { checkf(this->IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator().")); @@ -167,8 +167,8 @@ public: } /** Inserts characters from the range ['First', 'Last') before 'Index' in the string. */ - template S> requires (CConstructibleFrom>) - FORCEINLINE Iterator Insert(size_t Index, I First, S Last) + template S> requires (CConstructibleFrom>) + FORCEINLINE FIterator Insert(size_t Index, I First, S Last) { checkf(Index <= this->Num(), TEXT("Illegal index. Please check Index <= Num().")); @@ -176,16 +176,16 @@ public: } /** Inserts characters from the range ['First', 'Last') before 'Iter'. */ - template S> requires (CConstructibleFrom>) - FORCEINLINE Iterator Insert(ConstIterator Iter, I First, S Last) + template S> requires (CConstructibleFrom>) + FORCEINLINE FIterator Insert(FConstIterator Iter, I First, S Last) { checkf(this->IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator().")); - return Super::Insert(Iter, MoveTemp(First), MoveTemp(Last)); + return FSuper::Insert(Iter, MoveTemp(First), MoveTemp(Last)); } /** Inserts characters from the initializer list before 'Index' in the string. */ - FORCEINLINE Iterator Insert(size_t Index, initializer_list IL) + FORCEINLINE FIterator Insert(size_t Index, initializer_list IL) { checkf(Index <= this->Num(), TEXT("Illegal index. Please check Index <= Num().")); @@ -193,15 +193,15 @@ public: } /** Inserts characters from the initializer list before 'Iter' in the string. */ - FORCEINLINE Iterator Insert(ConstIterator Iter, initializer_list IL) + FORCEINLINE FIterator Insert(FConstIterator Iter, initializer_list IL) { checkf(this->IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator().")); - return Super::Insert(Iter, IL); + return FSuper::Insert(Iter, IL); } /** Erases the character at 'Index' in the string. But it may change the order of characters. */ - FORCEINLINE Iterator Erase(size_t Index, bool bAllowShrinking = true) + FORCEINLINE FIterator Erase(size_t Index, bool bAllowShrinking = true) { checkf(Index < this->Num(), TEXT("Illegal index. Please check Index < Num().")); @@ -209,15 +209,15 @@ public: } /** Erases the character at 'Iter' in the string. But it may change the order of characters. */ - FORCEINLINE Iterator Erase(ConstIterator Iter, bool bAllowShrinking = true) + FORCEINLINE FIterator Erase(FConstIterator Iter, bool bAllowShrinking = true) { checkf(this->IsValidIterator(Iter) && Iter != this->End(), TEXT("Read access violation. Please check IsValidIterator().")); - return Super::StableErase(Iter, bAllowShrinking); + return FSuper::StableErase(Iter, bAllowShrinking); } /** Erases 'CountToErase' characters starting from 'Index' in the string. But it may change the order of characters. */ - FORCEINLINE Iterator Erase(size_t Index, size_t CountToErase, bool bAllowShrinking = true) + FORCEINLINE FIterator Erase(size_t Index, size_t CountToErase, bool bAllowShrinking = true) { checkf(Index <= this->Num() && Index + CountToErase <= this->Num(), TEXT("Illegal substring range. Please check Index and CountToErase.")); @@ -226,24 +226,24 @@ public: } /** Erases the characters in the range ['First', 'Last') in the string. But it may change the order of characters. */ - FORCEINLINE Iterator Erase(ConstIterator First, ConstIterator Last, bool bAllowShrinking = true) + FORCEINLINE FIterator Erase(FConstIterator First, FConstIterator Last, bool bAllowShrinking = true) { checkf(this->IsValidIterator(First) && this->IsValidIterator(Last) && First <= Last, TEXT("Read access violation. Please check IsValidIterator().")); - return Super::StableErase(First, Last, bAllowShrinking); + return FSuper::StableErase(First, Last, bAllowShrinking); } /** Here, the 'Erase' is already stable and there is no need to provide 'StableErase'. */ void StableErase(...) = delete; /** Appends 'Count' copies of the 'InValue' to the end of the string. */ - TString& Append(size_t Count, ElementType InChar) { return Append(MakeCountedConstantIterator(InChar, Count), DefaultSentinel); } + TString& Append(size_t Count, FElementType InChar) { return Append(MakeCountedConstantIterator(InChar, Count), DefaultSentinel); } /** Appends the contents of the 'View' to the end of the string. */ - FORCEINLINE TString& Append(TStringView View) { return Append(View.Begin(), View.End()); } + FORCEINLINE TString& Append(TStringView View) { return Append(View.Begin(), View.End()); } /** Appends the contents of the range ['First', 'Last') to the end of the string. */ - template S> requires (CConstructibleFrom>) + template S> requires (CConstructibleFrom>) TString& Append(I First, S Last) { if constexpr (CForwardIterator) @@ -258,7 +258,7 @@ public: for (size_t Index = CurrentNum; Index != CurrentNum + Count; ++Index) { - (*this)[Index] = ElementType(*First++); + (*this)[Index] = FElementType(*First++); } } else @@ -270,40 +270,40 @@ public: } /** Appends the contents of the initializer list to the end of the string. */ - FORCEINLINE TString& Append(initializer_list IL) { return Append(Iteration::Begin(IL), Iteration::End(IL)); } + FORCEINLINE TString& Append(initializer_list IL) { return Append(Iteration::Begin(IL), Iteration::End(IL)); } /** Appends the given character value to the end of the string. */ - FORCEINLINE TString& operator+=(ElementType InChar) { return Append(1, InChar); } + FORCEINLINE TString& operator+=(FElementType InChar) { return Append(1, InChar); } /** Appends the contents of the 'View' to the end of the string. */ - FORCEINLINE TString& operator+=(TStringView View) { return Append(View); } + FORCEINLINE TString& operator+=(TStringView View) { return Append(View); } /** Appends the contents of the range ['First', 'Last') to the end of the string. */ - FORCEINLINE TString& operator+=(initializer_list IL) { return Append(IL); } + FORCEINLINE TString& operator+=(initializer_list IL) { return Append(IL); } /** Concatenates two strings. */ NODISCARD friend FORCEINLINE TString operator+(const TString& LHS, const TString& RHS) { return TString(LHS).Append(RHS); } /** Concatenates the string with the given character value. */ - NODISCARD friend FORCEINLINE TString operator+(const TString& LHS, ElementType RHS) { return TString(LHS).Append(1, RHS); } - NODISCARD friend FORCEINLINE TString operator+(const TString& LHS, const ElementType* RHS) { return TString(LHS).Append( RHS); } - NODISCARD friend FORCEINLINE TString operator+(const TString& LHS, TStringView RHS) { return TString(LHS).Append( RHS); } - NODISCARD friend FORCEINLINE TString operator+( ElementType LHS, const TString& RHS) { return TString(1, LHS).Append(RHS); } - NODISCARD friend FORCEINLINE TString operator+( const ElementType* LHS, const TString& RHS) { return TString( LHS).Append(RHS); } - NODISCARD friend FORCEINLINE TString operator+(TStringView LHS, const TString& RHS) { return TString( LHS).Append(RHS); } + NODISCARD friend FORCEINLINE TString operator+(const TString& LHS, FElementType RHS) { return TString(LHS).Append(1, RHS); } + NODISCARD friend FORCEINLINE TString operator+(const TString& LHS, const FElementType* RHS) { return TString(LHS).Append( RHS); } + NODISCARD friend FORCEINLINE TString operator+(const TString& LHS, TStringView RHS) { return TString(LHS).Append( RHS); } + NODISCARD friend FORCEINLINE TString operator+( FElementType LHS, const TString& RHS) { return TString(1, LHS).Append(RHS); } + NODISCARD friend FORCEINLINE TString operator+( const FElementType* LHS, const TString& RHS) { return TString( LHS).Append(RHS); } + NODISCARD friend FORCEINLINE TString operator+(TStringView LHS, const TString& RHS) { return TString( LHS).Append(RHS); } /** Concatenates two strings. The rvalue maybe modified. */ NODISCARD friend FORCEINLINE TString operator+(TString&& LHS, TString&& RHS) { LHS.Append(MoveTemp(RHS)); return LHS; } /** Concatenates two strings. The rvalue maybe modified. */ - NODISCARD friend FORCEINLINE TString operator+(TString&& LHS, ElementType RHS) { LHS.Append(1, RHS); return LHS; } - NODISCARD friend FORCEINLINE TString operator+(TString&& LHS, const ElementType* RHS) { LHS.Append( RHS); return LHS; } - NODISCARD friend FORCEINLINE TString operator+(TString&& LHS, TStringView RHS) { LHS.Append( RHS); return LHS; } - NODISCARD friend FORCEINLINE TString operator+(TString&& LHS, const TString& RHS) { LHS.Append( RHS); return LHS; } - NODISCARD friend FORCEINLINE TString operator+( ElementType LHS, TString&& RHS) { RHS.Insert(0, LHS); return RHS; } - NODISCARD friend FORCEINLINE TString operator+( const ElementType* LHS, TString&& RHS) { RHS.Insert(0, LHS); return RHS; } - NODISCARD friend FORCEINLINE TString operator+( TStringView LHS, TString&& RHS) { RHS.Insert(0, LHS); return RHS; } - NODISCARD friend FORCEINLINE TString operator+(const TString& LHS, TString&& RHS) { RHS.Insert(0, LHS); return RHS; } + NODISCARD friend FORCEINLINE TString operator+(TString&& LHS, FElementType RHS) { LHS.Append(1, RHS); return LHS; } + NODISCARD friend FORCEINLINE TString operator+(TString&& LHS, const FElementType* RHS) { LHS.Append( RHS); return LHS; } + NODISCARD friend FORCEINLINE TString operator+(TString&& LHS, TStringView RHS) { LHS.Append( RHS); return LHS; } + NODISCARD friend FORCEINLINE TString operator+(TString&& LHS, const TString& RHS) { LHS.Append( RHS); return LHS; } + NODISCARD friend FORCEINLINE TString operator+( FElementType LHS, TString&& RHS) { RHS.Insert(0, LHS); return RHS; } + NODISCARD friend FORCEINLINE TString operator+( const FElementType* LHS, TString&& RHS) { RHS.Insert(0, LHS); return RHS; } + NODISCARD friend FORCEINLINE TString operator+( TStringView LHS, TString&& RHS) { RHS.Insert(0, LHS); return RHS; } + NODISCARD friend FORCEINLINE TString operator+(const TString& LHS, TString&& RHS) { RHS.Insert(0, LHS); return RHS; } public: @@ -330,7 +330,7 @@ public: /** Removes whitespace characters from the start of this string. */ FORCEINLINE constexpr TString& TrimStart(bool bAllowShrinking = true) { - auto Index = Find([](ElementType Char) { return !TChar::IsSpace(Char); }); + auto Index = Find([](FElementType Char) { return !TChar::IsSpace(Char); }); if (Index != INDEX_NONE) { @@ -344,7 +344,7 @@ public: /** Removes whitespace characters from the end of this string. */ FORCEINLINE constexpr TString& TrimEnd(bool bAllowShrinking = true) { - auto Index = RFind([](ElementType Char) { return !TChar::IsSpace(Char); }); + auto Index = RFind([](FElementType Char) { return !TChar::IsSpace(Char); }); if (Index != INDEX_NONE) { @@ -367,7 +367,7 @@ public: /** Removes characters after the first null-terminator. */ FORCEINLINE constexpr TString& TrimToNullTerminator(bool bAllowShrinking = true) { - auto Index = Find(LITERAL(ElementType, '\0')); + auto Index = Find(LITERAL(FElementType, '\0')); if (Index != INDEX_NONE) { @@ -380,50 +380,50 @@ public: public: /** @return true if the string view starts with the given prefix, false otherwise. */ - NODISCARD FORCEINLINE bool StartsWith(TStringView Prefix) const + NODISCARD FORCEINLINE bool StartsWith(TStringView Prefix) const { - return TStringView(*this).StartsWith(Prefix); + return TStringView(*this).StartsWith(Prefix); } /** @return true if the string view starts with the given prefix, false otherwise. */ - NODISCARD FORCEINLINE bool StartsWith(ElementType Prefix) const + NODISCARD FORCEINLINE bool StartsWith(FElementType Prefix) const { - return TStringView(*this).StartsWith(Prefix); + return TStringView(*this).StartsWith(Prefix); } /** @return true if the string view ends with the given suffix, false otherwise. */ - NODISCARD FORCEINLINE bool EndsWith(TStringView Suffix) const + NODISCARD FORCEINLINE bool EndsWith(TStringView Suffix) const { - return TStringView(*this).EndsWith(Suffix); + return TStringView(*this).EndsWith(Suffix); } /** @return true if the string view ends with the given suffix, false otherwise. */ - NODISCARD FORCEINLINE bool EndsWith(ElementType Suffix) const + NODISCARD FORCEINLINE bool EndsWith(FElementType Suffix) const { - return TStringView(*this).EndsWith(Suffix); + return TStringView(*this).EndsWith(Suffix); } /** @return true if the string view contains the given substring, false otherwise. */ - NODISCARD FORCEINLINE bool Contains(TStringView View) const + NODISCARD FORCEINLINE bool Contains(TStringView View) const { - return TStringView(*this).Contains(View); + return TStringView(*this).Contains(View); } /** @return true if the string view contains the given character, false otherwise. */ - NODISCARD FORCEINLINE bool Contains(ElementType Char) const + NODISCARD FORCEINLINE bool Contains(FElementType Char) const { - return TStringView(*this).Contains(Char); + return TStringView(*this).Contains(Char); } /** @return true if the string view contains character that satisfy the given predicate, false otherwise. */ - template F> + template F> NODISCARD FORCEINLINE bool Contains(F&& InPredicate) const { - return TStringView(*this).Contains(Forward(InPredicate)); + return TStringView(*this).Contains(Forward(InPredicate)); } /** Replace the substring [Index, Index + CountToReplace) with 'Count' copies of the 'InChar'. */ - FORCEINLINE TString& Replace(size_t Index, size_t CountToReplace, size_t Count, ElementType InChar) + FORCEINLINE TString& Replace(size_t Index, size_t CountToReplace, size_t Count, FElementType InChar) { checkf(Index <= this->Num() && Index + CountToReplace <= this->Num(), TEXT("Illegal substring range. Please check Index and CountToReplace.")); @@ -431,7 +431,7 @@ public: } /** Replace the substring ['First', 'Last') with 'Count' copies of the 'InChar'. */ - FORCEINLINE TString& Replace(ConstIterator First, ConstIterator Last, size_t Count, ElementType InChar) + FORCEINLINE TString& Replace(FConstIterator First, FConstIterator Last, size_t Count, FElementType InChar) { checkf(this->IsValidIterator(First) && this->IsValidIterator(Last) && First <= Last, TEXT("Read access violation. Please check IsValidIterator().")); @@ -439,7 +439,7 @@ public: } /** Replace the substring [Index, Index + CountToReplace) with the contents of the 'View'. */ - FORCEINLINE TString& Replace(size_t Index, size_t CountToReplace, TStringView View) + FORCEINLINE TString& Replace(size_t Index, size_t CountToReplace, TStringView View) { checkf(Index <= this->Num() && Index + CountToReplace <= this->Num(), TEXT("Illegal substring range. Please check Index and CountToReplace.")); @@ -447,7 +447,7 @@ public: } /** Replace the substring ['First', 'Last') with the contents of the 'View'. */ - FORCEINLINE TString& Replace(ConstIterator First, ConstIterator Last, TStringView View) + FORCEINLINE TString& Replace(FConstIterator First, FConstIterator Last, TStringView View) { checkf(this->IsValidIterator(First) && this->IsValidIterator(Last) && First <= Last, TEXT("Read access violation. Please check IsValidIterator().")); @@ -455,7 +455,7 @@ public: } /** Replace the substring [Index, Index + CountToReplace) with the contents of the range ['First', 'Last'). */ - template S> requires (CConstructibleFrom>) + template S> requires (CConstructibleFrom>) FORCEINLINE TString& Replace(size_t Index, size_t CountToReplace, I InString, S Sentinel) { checkf(Index <= this->Num() && Index + CountToReplace <= this->Num(), TEXT("Illegal substring range. Please check Index and CountToReplace.")); @@ -464,8 +464,8 @@ public: } /** Replace the substring ['First', 'Last') with the contents of the range ['InString', 'Sentinel'). */ - template S> requires (CConstructibleFrom>) - TString& Replace(ConstIterator First, ConstIterator Last, I InString, S Sentinel) + template S> requires (CConstructibleFrom>) + TString& Replace(FConstIterator First, FConstIterator Last, I InString, S Sentinel) { checkf(this->IsValidIterator(First) && this->IsValidIterator(Last) && First <= Last, TEXT("Read access violation. Please check IsValidIterator().")); @@ -484,7 +484,7 @@ public: { for (size_t Index = InsertIndex; Index != InsertIndex + InsertCount; ++Index) { - (*this)[Index] = ElementType(*InString++); + (*this)[Index] = FElementType(*InString++); } for (size_t Index = InsertIndex + InsertCount; Index != NumToReset; ++Index) @@ -505,7 +505,7 @@ public: for (size_t Index = InsertIndex; Index != InsertIndex + InsertCount; ++Index) { - (*this)[Index] = ElementType(*InString++); + (*this)[Index] = FElementType(*InString++); } } } @@ -520,7 +520,7 @@ public: } /** Replace the substring [Index, Index + CountToReplace) with the contents of the initializer list. */ - FORCEINLINE TString& Replace(size_t Index, size_t CountToReplace, initializer_list IL) + FORCEINLINE TString& Replace(size_t Index, size_t CountToReplace, initializer_list IL) { checkf(Index <= this->Num() && Index + CountToReplace <= this->Num(), TEXT("Illegal substring range. Please check Index and CountToReplace.")); @@ -528,7 +528,7 @@ public: } /** Replace the substring ['First', 'Last') with the contents of the initializer list. */ - FORCEINLINE TString& Replace(ConstIterator First, ConstIterator Last, initializer_list IL) + FORCEINLINE TString& Replace(FConstIterator First, FConstIterator Last, initializer_list IL) { checkf(this->IsValidIterator(First) && this->IsValidIterator(Last) && First <= Last, TEXT("Read access violation. Please check IsValidIterator().")); @@ -540,133 +540,133 @@ public: { checkf(Offset <= this->Num() && Offset + Count <= this->Num(), TEXT("Illegal substring range. Please check Offset and Count.")); - return TStringView(*this).Substr(Offset, Count); + return TStringView(*this).Substr(Offset, Count); } /** Copies the characters of this string to the destination buffer without null-termination. */ - FORCEINLINE size_t Copy(ElementType* Dest, size_t Count = DynamicExtent, size_t Offset = 0) const + FORCEINLINE size_t Copy(FElementType* Dest, size_t Count = DynamicExtent, size_t Offset = 0) const { checkf(Dest != nullptr, TEXT("Illegal destination buffer. Please check the pointer.")); checkf(Offset <= this->Num() && (Count == DynamicExtent || Offset + Count <= this->Num()), TEXT("Illegal subview range. Please check Offset and Count.")); - return TStringView(*this).Copy(Dest, Count, Offset); + return TStringView(*this).Copy(Dest, Count, Offset); } FORCEINLINE size_t Copy(nullptr_t, size_t = DynamicExtent, size_t = 0) const = delete; /** @return The index of the first occurrence of the given substring, or INDEX_NONE if not found. */ - NODISCARD size_t Find(TStringView View, size_t Index = 0) const + NODISCARD size_t Find(TStringView View, size_t Index = 0) const { checkf(Index < this->Num(), TEXT("Illegal index. Please check Index.")); - return TStringView(*this).Find(View, Index); + return TStringView(*this).Find(View, Index); } /** @return The index of the first occurrence of the given character, or INDEX_NONE if not found. */ - NODISCARD size_t Find(ElementType Char, size_t Index = 0) const + NODISCARD size_t Find(FElementType Char, size_t Index = 0) const { checkf(Index < this->Num(), TEXT("Illegal index. Please check Index.")); - return TStringView(*this).Find(Char, Index); + return TStringView(*this).Find(Char, Index); } /** @return The index of the first occurrence of the character that satisfy the given predicate, or INDEX_NONE if not found. */ - template F> + template F> NODISCARD size_t Find(F&& InPredicate, size_t Index = 0) const { checkf(Index < this->Num(), TEXT("Illegal index. Please check Index.")); - return TStringView(*this).Find(Forward(InPredicate), Index); + return TStringView(*this).Find(Forward(InPredicate), Index); } /** @return The index of the last occurrence of the given substring, or INDEX_NONE if not found. */ - NODISCARD size_t RFind(TStringView View, size_t Index = INDEX_NONE) const + NODISCARD size_t RFind(TStringView View, size_t Index = INDEX_NONE) const { checkf(Index == INDEX_NONE || Index < this->Num(), TEXT("Illegal index. Please check Index.")); - return TStringView(*this).RFind(View, Index); + return TStringView(*this).RFind(View, Index); } /** @return The index of the last occurrence of the given character, or INDEX_NONE if not found. */ - NODISCARD size_t RFind(ElementType Char, size_t Index = INDEX_NONE) const + NODISCARD size_t RFind(FElementType Char, size_t Index = INDEX_NONE) const { checkf(Index == INDEX_NONE || Index < this->Num(), TEXT("Illegal index. Please check Index.")); - return TStringView(*this).RFind(Char, Index); + return TStringView(*this).RFind(Char, Index); } /** @return The index of the last occurrence of the character that satisfy the given predicate, or INDEX_NONE if not found. */ - template F> + template F> NODISCARD size_t RFind(F&& InPredicate, size_t Index = INDEX_NONE) const { checkf(Index == INDEX_NONE || Index < this->Num(), TEXT("Illegal index. Please check Index.")); - return TStringView(*this).RFind(Forward(InPredicate), Index); + return TStringView(*this).RFind(Forward(InPredicate), Index); } /** @return The index of the first occurrence of the character contained in the given view, or INDEX_NONE if not found. */ - NODISCARD FORCEINLINE size_t FindFirstOf(TStringView View, size_t Index = 0) const + NODISCARD FORCEINLINE size_t FindFirstOf(TStringView View, size_t Index = 0) const { checkf(Index < this->Num(), TEXT("Illegal index. Please check Index.")); - return TStringView(*this).FindFirstOf(View, Index); + return TStringView(*this).FindFirstOf(View, Index); } /** @return The index of the first occurrence of the given character, or INDEX_NONE if not found. */ - NODISCARD FORCEINLINE size_t FindFirstOf(ElementType Char, size_t Index = 0) const + NODISCARD FORCEINLINE size_t FindFirstOf(FElementType Char, size_t Index = 0) const { checkf(Index < this->Num(), TEXT("Illegal index. Please check Index.")); - return TStringView(*this).FindFirstOf(Char, Index); + return TStringView(*this).FindFirstOf(Char, Index); } /** @return The index of the last occurrence of the character contained in the given view, or INDEX_NONE if not found. */ - NODISCARD FORCEINLINE size_t FindLastOf(TStringView View, size_t Index = INDEX_NONE) const + NODISCARD FORCEINLINE size_t FindLastOf(TStringView View, size_t Index = INDEX_NONE) const { checkf(Index == INDEX_NONE || Index < this->Num(), TEXT("Illegal index. Please check Index.")); - return TStringView(*this).FindLastOf(View, Index); + return TStringView(*this).FindLastOf(View, Index); } /** @return The index of the last occurrence of the given character, or INDEX_NONE if not found. */ - NODISCARD FORCEINLINE size_t FindLastOf(ElementType Char, size_t Index = INDEX_NONE) const + NODISCARD FORCEINLINE size_t FindLastOf(FElementType Char, size_t Index = INDEX_NONE) const { checkf(Index == INDEX_NONE || Index < this->Num(), TEXT("Illegal index. Please check Index.")); - return TStringView(*this).FindLastOf(Char, Index); + return TStringView(*this).FindLastOf(Char, Index); } /** @return The index of the first absence of the character contained in the given view, or INDEX_NONE if not found. */ - NODISCARD FORCEINLINE size_t FindFirstNotOf(TStringView View, size_t Index = 0) const + NODISCARD FORCEINLINE size_t FindFirstNotOf(TStringView View, size_t Index = 0) const { checkf(Index < this->Num(), TEXT("Illegal index. Please check Index.")); - return TStringView(*this).FindFirstNotOf(View, Index); + return TStringView(*this).FindFirstNotOf(View, Index); } /** @return The index of the first absence of the given character, or INDEX_NONE if not found. */ - NODISCARD FORCEINLINE size_t FindFirstNotOf(ElementType Char, size_t Index = 0) const + NODISCARD FORCEINLINE size_t FindFirstNotOf(FElementType Char, size_t Index = 0) const { checkf(Index < this->Num(), TEXT("Illegal index. Please check Index.")); - return TStringView(*this).FindFirstNotOf(Char, Index); + return TStringView(*this).FindFirstNotOf(Char, Index); } /** @return The index of the last absence of the character contained in the given view, or INDEX_NONE if not found. */ - NODISCARD FORCEINLINE size_t FindLastNotOf(TStringView View, size_t Index = INDEX_NONE) const + NODISCARD FORCEINLINE size_t FindLastNotOf(TStringView View, size_t Index = INDEX_NONE) const { checkf(Index == INDEX_NONE || Index < this->Num(), TEXT("Illegal index. Please check Index.")); - return TStringView(*this).FindLastNotOf(View, Index); + return TStringView(*this).FindLastNotOf(View, Index); } /** @return The index of the last absence of the given character, or INDEX_NONE if not found. */ - NODISCARD FORCEINLINE size_t FindLastNotOf(ElementType Char, size_t Index = INDEX_NONE) const + NODISCARD FORCEINLINE size_t FindLastNotOf(FElementType Char, size_t Index = INDEX_NONE) const { checkf(Index == INDEX_NONE || Index < this->Num(), TEXT("Illegal index. Please check Index.")); - return TStringView(*this).FindLastNotOf(Char, Index); + return TStringView(*this).FindLastNotOf(Char, Index); } public: @@ -1028,7 +1028,7 @@ public: { if (this->Max() >= this->Num() + 1) { - const_cast(this->GetData())[this->Num()] = LITERAL(ElementType, '\0'); + const_cast(this->GetData())[this->Num()] = LITERAL(FElementType, '\0'); return *TStringView(this->GetData(), this->Num() + 1); } @@ -1052,31 +1052,31 @@ public: /** @return true if the string only contains valid characters, false otherwise. */ NODISCARD FORCEINLINE bool IsValid() const { - return TStringView(*this).IsValid(); + return TStringView(*this).IsValid(); } /** @return true if the string only contains ASCII characters, false otherwise. */ NODISCARD FORCEINLINE bool IsASCII() const { - return TStringView(*this).IsASCII(); + return TStringView(*this).IsASCII(); } /** @return true if the string can be fully represented as a boolean value, false otherwise. */ NODISCARD FORCEINLINE bool IsBoolean() const { - return TStringView(*this).IsBoolean(); + return TStringView(*this).IsBoolean(); } /** @return true if the string can be fully represented as an integer value, false otherwise. */ NODISCARD FORCEINLINE bool IsInteger(unsigned Base = 10, bool bSigned = true) const { - return TStringView(*this).IsInteger(Base, bSigned); + return TStringView(*this).IsInteger(Base, bSigned); } /** @return true if the string can be fully represented as a floating-point value, false otherwise. */ NODISCARD FORCEINLINE bool IsFloatingPoint(bool bFixed = true, bool bScientific = true, bool bSigned = true) const { - return TStringView(*this).IsFloatingPoint(bFixed, bScientific, bSigned); + return TStringView(*this).IsFloatingPoint(bFixed, bScientific, bSigned); } public: @@ -1202,7 +1202,7 @@ public: */ NODISCARD FORCEINLINE bool ToBool() const { - return TStringView(*this).ToBool(); + return TStringView(*this).ToBool(); } /** @@ -1223,7 +1223,7 @@ public: { checkf(Base >= 2 && Base <= 36, TEXT("Illegal base. Please check the base.")); - return TStringView(*this).template ToInt(Base); + return TStringView(*this).template ToInt(Base); } /** @@ -1244,13 +1244,13 @@ public: template requires (!CConst && !CVolatile) NODISCARD FORCEINLINE U ToFloat(bool bFixed = true, bool bScientific = false) const { - return TStringView(*this).template ToFloat(bFixed, bScientific); + return TStringView(*this).template ToFloat(bFixed, bScientific); } /** Converts a string into a boolean value and remove the parsed substring. */ NODISCARD FORCEINLINE bool ToBoolAndTrim() { - TStringView View = *this; + TStringView View = *this; bool Result = View.ToBoolAndTrim(); @@ -1265,7 +1265,7 @@ public: template requires (!CSameAs && !CConst && !CVolatile) NODISCARD FORCEINLINE U ToIntAndTrim(unsigned Base = 10) { - TStringView View = *this; + TStringView View = *this; U Result = View.template ToIntAndTrim(Base); @@ -1280,7 +1280,7 @@ public: template requires (!CConst && !CVolatile) NODISCARD FORCEINLINE U ToFloatAndTrim(bool bFixed = true, bool bScientific = true) { - TStringView View = *this; + TStringView View = *this; U Result = View.template ToFloatAndTrim(bFixed, bScientific); @@ -1302,7 +1302,7 @@ public: * @return The formatted string containing the objects. */ template - NODISCARD static FORCEINLINE TString Format(TStringView Fmt, const Ts&... Args) + NODISCARD static FORCEINLINE TString Format(TStringView Fmt, const Ts&... Args) { TString Result; @@ -1313,7 +1313,7 @@ public: /** Format some objects using a format string and append to the string. */ template - void AppendFormat(TStringView Fmt, const Ts&... Args); + void AppendFormat(TStringView Fmt, const Ts&... Args); /** * Parse a string using a format string to objects. @@ -1324,16 +1324,16 @@ public: * @return The number of objects successfully parsed. */ template - FORCEINLINE size_t Parse(TStringView Fmt, Ts&... Args) const + FORCEINLINE size_t Parse(TStringView Fmt, Ts&... Args) const { return TStringView(*this).Parse(Fmt, Args...); } /** Parse a string using a format string to objects and remove the parsed substring. */ template - FORCEINLINE size_t ParseAndTrim(TStringView Fmt, Ts&... Args) + FORCEINLINE size_t ParseAndTrim(TStringView Fmt, Ts&... Args) { - TStringView View = *this; + TStringView View = *this; size_t Result = View.ParseAndTrim(Fmt, Args...); @@ -1347,10 +1347,10 @@ public: public: /** Overloads the GetTypeHash algorithm for TString. */ - NODISCARD friend FORCEINLINE size_t GetTypeHash(const TString& A) { return GetTypeHash(TStringView(A)); } + NODISCARD friend FORCEINLINE size_t GetTypeHash(const TString& A) { return GetTypeHash(TStringView(A)); } /** Overloads the Swap algorithm for TString. */ - friend FORCEINLINE void Swap(TString& A, TString& B) { Swap(static_cast(A), static_cast(B)); } + friend FORCEINLINE void Swap(TString& A, TString& B) { Swap(static_cast(A), static_cast(B)); } }; @@ -1373,7 +1373,7 @@ using FU16String = TString; using FU32String = TString; using FUnicodeString = TString; -template template constexpr TStringView::TStringView(const TString& InString) +template template constexpr TStringView::TStringView(const TString& InString) : TStringView(InString.GetData(), InString.Num()) { } NAMESPACE_MODULE_END(Utility) diff --git a/Redcraft.Utility/Source/Public/String/StringView.h b/Redcraft.Utility/Source/Public/String/StringView.h index 5524e16..b899757 100644 --- a/Redcraft.Utility/Source/Public/String/StringView.h +++ b/Redcraft.Utility/Source/Public/String/StringView.h @@ -82,36 +82,36 @@ class TStringView : public TArrayView { private: - using Super = TArrayView; + using FSuper = TArrayView; public: - using ElementType = T; + using FElementType = T; - using Reference = typename Super::Reference; + using FReference = typename FSuper::FReference; - using Iterator = typename Super::Iterator; - using ReverseIterator = typename Super::ReverseIterator; + using FIterator = typename FSuper:: FIterator; + using FReverseIterator = typename FSuper::FReverseIterator; - static_assert(CContiguousIterator); + static_assert(CContiguousIterator); /** Constructs an empty string view. */ FORCEINLINE constexpr TStringView() = default; /** Constructs a string view that is a view over the range ['InFirst', 'InFirst' + 'Count'). */ - template requires (CConvertibleTo(*)[], const ElementType(*)[]>) - FORCEINLINE constexpr TStringView(I InFirst, size_t InCount) : Super(InFirst, InCount) { } + template requires (CConvertibleTo(*)[], const FElementType(*)[]>) + FORCEINLINE constexpr TStringView(I InFirst, size_t InCount) : FSuper(InFirst, InCount) { } /** Constructs a string view that is a view over the range ['InFirst', 'InLast'). */ - template S> requires (CConvertibleTo(*)[], const ElementType(*)[]>) - FORCEINLINE constexpr TStringView(I InFirst, S InLast) : Super(InFirst, InLast) { } + template S> requires (CConvertibleTo(*)[], const FElementType(*)[]>) + FORCEINLINE constexpr TStringView(I InFirst, S InLast) : FSuper(InFirst, InLast) { } /** Constructs a string view that is a view over the string 'InString'. */ template - FORCEINLINE constexpr TStringView(const TString& InString); + FORCEINLINE constexpr TStringView(const TString& InString); /** Constructs a string view that is a view over the range ['InPtr', 'InPtr' + 'Count'). */ - FORCEINLINE constexpr TStringView(const ElementType* InPtr, size_t Count) : Super(InPtr, Count) + FORCEINLINE constexpr TStringView(const FElementType* InPtr, size_t Count) : FSuper(InPtr, Count) { checkf(InPtr != nullptr, TEXT("TStringView cannot be initialized by nullptr. Please check the pointer.")); } @@ -119,23 +119,23 @@ public: FORCEINLINE constexpr TStringView(nullptr_t, size_t) = delete; /** Constructs a string view that is a view over the range ['InPtr', '\0'). */ - FORCEINLINE constexpr TStringView(const ElementType* InPtr) + FORCEINLINE constexpr TStringView(const FElementType* InPtr) { checkf(InPtr != nullptr, TEXT("TStringView cannot be initialized by nullptr. Please check the pointer.")); size_t Length = 0; - if constexpr (CSameAs) + if constexpr (CSameAs) { Length = NAMESPACE_STD::strlen(InPtr); } - else if constexpr (CSameAs) + else if constexpr (CSameAs) { Length = NAMESPACE_STD::wcslen(InPtr); } else { - while (InPtr[Length] != LITERAL(ElementType, '\0')) ++Length; + while (InPtr[Length] != LITERAL(FElementType, '\0')) ++Length; } *this = TStringView(InPtr, Length); @@ -150,18 +150,18 @@ public: FORCEINLINE constexpr TStringView& operator=(const TStringView&) noexcept = default; /** Compares the contents of two string views. */ - NODISCARD friend constexpr bool operator==(TStringView LHS, TStringView RHS) { return static_cast(LHS) == static_cast(RHS); } + NODISCARD friend constexpr bool operator==(TStringView LHS, TStringView RHS) { return static_cast(LHS) == static_cast(RHS); } /** Compares the contents of a string view and a character. */ - NODISCARD friend constexpr bool operator==(TStringView LHS, ElementType RHS) { return LHS == TStringView(&RHS, 1); } - NODISCARD friend constexpr bool operator==(ElementType LHS, TStringView RHS) { return TStringView(&LHS, 1) == RHS; } + NODISCARD friend constexpr bool operator==(TStringView LHS, FElementType RHS) { return LHS == TStringView(&RHS, 1); } + NODISCARD friend constexpr bool operator==(FElementType LHS, TStringView RHS) { return TStringView(&LHS, 1) == RHS; } /** Compares the contents of two string views. */ - NODISCARD friend constexpr auto operator<=>(TStringView LHS, TStringView RHS) { return static_cast(LHS) <=> static_cast(RHS); } + NODISCARD friend constexpr auto operator<=>(TStringView LHS, TStringView RHS) { return static_cast(LHS) <=> static_cast(RHS); } /** Compares the contents of a string view and a character. */ - NODISCARD friend constexpr auto operator<=>(TStringView LHS, ElementType RHS) { return LHS <=> TStringView(&RHS, 1); } - NODISCARD friend constexpr auto operator<=>(ElementType LHS, TStringView RHS) { return TStringView(&LHS, 1) <=> RHS; } + NODISCARD friend constexpr auto operator<=>(TStringView LHS, FElementType RHS) { return LHS <=> TStringView(&RHS, 1); } + NODISCARD friend constexpr auto operator<=>(FElementType LHS, TStringView RHS) { return TStringView(&LHS, 1) <=> RHS; } public: @@ -188,7 +188,7 @@ public: /** Removes whitespace characters from the start of this string. */ FORCEINLINE constexpr TStringView& TrimStart() { - auto Index = Find([](ElementType Char) { return !TChar::IsSpace(Char); }); + auto Index = Find([](FElementType Char) { return !TChar::IsSpace(Char); }); if (Index != INDEX_NONE) { @@ -202,7 +202,7 @@ public: /** Removes whitespace characters from the end of this string. */ FORCEINLINE constexpr TStringView& TrimEnd() { - auto Index = RFind([](ElementType Char) { return !TChar::IsSpace(Char); }); + auto Index = RFind([](FElementType Char) { return !TChar::IsSpace(Char); }); if (Index != INDEX_NONE) { @@ -225,7 +225,7 @@ public: /** Removes characters after the first null-terminator. */ FORCEINLINE constexpr TStringView& TrimToNullTerminator() { - auto Index = Find(LITERAL(ElementType, '\0')); + auto Index = Find(LITERAL(FElementType, '\0')); if (Index != INDEX_NONE) { @@ -238,7 +238,7 @@ public: public: /** Copies the elements of this string view to the destination buffer without null-termination. */ - FORCEINLINE constexpr size_t Copy(ElementType* Dest, size_t Count = DynamicExtent, size_t Offset = 0) const + FORCEINLINE constexpr size_t Copy(FElementType* Dest, size_t Count = DynamicExtent, size_t Offset = 0) const { checkf(Dest != nullptr, TEXT("Illegal destination buffer. Please check the pointer.")); @@ -277,7 +277,7 @@ public: { checkf(Offset <= this->Num() && (Count == DynamicExtent || Offset + Count <= this->Num()), TEXT("Illegal subview range. Please check Offset and Count.")); - Super Temp = this->Subview(Offset, Count); + FSuper Temp = this->Subview(Offset, Count); return TStringView(Temp.GetData(), Temp.Num()); } @@ -289,7 +289,7 @@ public: } /** @return true if the string view starts with the given prefix, false otherwise. */ - NODISCARD FORCEINLINE constexpr bool StartsWith(ElementType Prefix) const + NODISCARD FORCEINLINE constexpr bool StartsWith(FElementType Prefix) const { return this->Num() >= 1 && this->Front() == Prefix; } @@ -301,7 +301,7 @@ public: } /** @return true if the string view ends with the given suffix, false otherwise. */ - NODISCARD FORCEINLINE constexpr bool EndsWith(ElementType Suffix) const + NODISCARD FORCEINLINE constexpr bool EndsWith(FElementType Suffix) const { return this->Num() >= 1 && this->Back() == Suffix; } @@ -313,13 +313,13 @@ public: } /** @return true if the string view contains the given character, false otherwise. */ - NODISCARD FORCEINLINE constexpr bool Contains(ElementType Char) const + NODISCARD FORCEINLINE constexpr bool Contains(FElementType Char) const { return Find(Char) != INDEX_NONE; } /** @return true if the string view contains character that satisfy the given predicate, false otherwise. */ - template F> + template F> NODISCARD FORCEINLINE constexpr bool Contains(F&& InPredicate) const { return Find(Forward(InPredicate)) != INDEX_NONE; @@ -346,7 +346,7 @@ public: } /** @return The index of the first occurrence of the given character, or INDEX_NONE if not found. */ - NODISCARD constexpr size_t Find(ElementType Char, size_t Index = 0) const + NODISCARD constexpr size_t Find(FElementType Char, size_t Index = 0) const { if (Index >= this->Num()) return INDEX_NONE; @@ -362,7 +362,7 @@ public: } /** @return The index of the first occurrence of the character that satisfy the given predicate, or INDEX_NONE if not found. */ - template F> + template F> NODISCARD constexpr size_t Find(F&& InPredicate, size_t Index = 0) const { if (Index >= this->Num()) return INDEX_NONE; @@ -401,7 +401,7 @@ public: } /** @return The index of the last occurrence of the given character, or INDEX_NONE if not found. */ - NODISCARD constexpr size_t RFind(ElementType Char, size_t Index = INDEX_NONE) const + NODISCARD constexpr size_t RFind(FElementType Char, size_t Index = INDEX_NONE) const { if (Index != INDEX_NONE && Index >= this->Num()) return INDEX_NONE; @@ -419,7 +419,7 @@ public: } /** @return The index of the last occurrence of the character that satisfy the given predicate, or INDEX_NONE if not found. */ - template F> + template F> NODISCARD constexpr size_t RFind(F&& InPredicate, size_t Index = INDEX_NONE) const { if (Index != INDEX_NONE && Index >= this->Num()) return INDEX_NONE; @@ -440,11 +440,11 @@ public: /** @return The index of the first occurrence of the character contained in the given view, or INDEX_NONE if not found. */ NODISCARD FORCEINLINE constexpr size_t FindFirstOf(TStringView View, size_t Index = 0) const { - return Find([View](ElementType Char) { return View.Contains(Char); }, Index); + return Find([View](FElementType Char) { return View.Contains(Char); }, Index); } /** @return The index of the first occurrence of the given character, or INDEX_NONE if not found. */ - NODISCARD FORCEINLINE constexpr size_t FindFirstOf(ElementType Char, size_t Index = 0) const + NODISCARD FORCEINLINE constexpr size_t FindFirstOf(FElementType Char, size_t Index = 0) const { return Find(Char, Index); } @@ -452,11 +452,11 @@ public: /** @return The index of the last occurrence of the character contained in the given view, or INDEX_NONE if not found. */ NODISCARD FORCEINLINE constexpr size_t FindLastOf(TStringView View, size_t Index = INDEX_NONE) const { - return RFind([View](ElementType Char) { return View.Contains(Char); }, Index); + return RFind([View](FElementType Char) { return View.Contains(Char); }, Index); } /** @return The index of the last occurrence of the given character, or INDEX_NONE if not found. */ - NODISCARD FORCEINLINE constexpr size_t FindLastOf(ElementType Char, size_t Index = INDEX_NONE) const + NODISCARD FORCEINLINE constexpr size_t FindLastOf(FElementType Char, size_t Index = INDEX_NONE) const { return RFind(Char, Index); } @@ -464,25 +464,25 @@ public: /** @return The index of the first absence of the character contained in the given view, or INDEX_NONE if not found. */ NODISCARD FORCEINLINE constexpr size_t FindFirstNotOf(TStringView View, size_t Index = 0) const { - return Find([View](ElementType Char) { return !View.Contains(Char); }, Index); + return Find([View](FElementType Char) { return !View.Contains(Char); }, Index); } /** @return The index of the first absence of the given character, or INDEX_NONE if not found. */ - NODISCARD FORCEINLINE constexpr size_t FindFirstNotOf(ElementType Char, size_t Index = 0) const + NODISCARD FORCEINLINE constexpr size_t FindFirstNotOf(FElementType Char, size_t Index = 0) const { - return Find([Char](ElementType C) { return C != Char; }, Index); + return Find([Char](FElementType C) { return C != Char; }, Index); } /** @return The index of the last absence of the character contained in the given view, or INDEX_NONE if not found. */ NODISCARD FORCEINLINE constexpr size_t FindLastNotOf(TStringView View, size_t Index = INDEX_NONE) const { - return RFind([View](ElementType Char) { return !View.Contains(Char); }, Index); + return RFind([View](FElementType Char) { return !View.Contains(Char); }, Index); } /** @return The index of the last absence of the given character, or INDEX_NONE if not found. */ - NODISCARD FORCEINLINE constexpr size_t FindLastNotOf(ElementType Char, size_t Index = INDEX_NONE) const + NODISCARD FORCEINLINE constexpr size_t FindLastNotOf(FElementType Char, size_t Index = INDEX_NONE) const { - return RFind([Char](ElementType C) { return C != Char; }, Index); + return RFind([Char](FElementType C) { return C != Char; }, Index); } public: @@ -490,18 +490,18 @@ public: /** @return The non-modifiable standard C character string version of the string view. */ NODISCARD FORCEINLINE auto operator*() const { - if (this->Back() == LITERAL(ElementType, '\0') || Contains(LITERAL(ElementType, '\0'))) + if (this->Back() == LITERAL(FElementType, '\0') || Contains(LITERAL(FElementType, '\0'))) { - return NAMESPACE_PRIVATE::TCStringFromTStringView(this->GetData(), false); + return NAMESPACE_PRIVATE::TCStringFromTStringView(this->GetData(), false); } - ElementType* Buffer = new ElementType[this->Num() + 1]; + FElementType* Buffer = new FElementType[this->Num() + 1]; Copy(Buffer); - Buffer[this->Num()] = LITERAL(ElementType, '\0'); + Buffer[this->Num()] = LITERAL(FElementType, '\0'); - return NAMESPACE_PRIVATE::TCStringFromTStringView(Buffer, true); + return NAMESPACE_PRIVATE::TCStringFromTStringView(Buffer, true); } public: @@ -509,9 +509,9 @@ public: /** @return true if the string only contains valid characters, false otherwise. */ NODISCARD constexpr bool IsValid() const { - for (ElementType Char : *this) + for (FElementType Char : *this) { - if (!TChar::IsValid(Char)) return false; + if (!TChar::IsValid(Char)) return false; } return true; @@ -520,9 +520,9 @@ public: /** @return true if the string only contains ASCII characters, false otherwise. */ NODISCARD constexpr bool IsASCII() const { - for (ElementType Char : *this) + for (FElementType Char : *this) { - if (!TChar::IsASCII(Char)) return false; + if (!TChar::IsASCII(Char)) return false; } return true; @@ -543,7 +543,7 @@ public: { TStringView View = *this; - if (View.StartsWith(LITERAL(ElementType, '-'))) + if (View.StartsWith(LITERAL(FElementType, '-'))) { if (bSigned) View.RemovePrefix(1); else return false; @@ -559,7 +559,7 @@ public: { TStringView View = *this; - if (View.StartsWith(LITERAL(ElementType, '-'))) + if (View.StartsWith(LITERAL(FElementType, '-'))) { if (bSigned) View.RemovePrefix(1); else return false; @@ -659,7 +659,7 @@ public: public: /** Overloads the GetTypeHash algorithm for TStringView. */ - NODISCARD friend FORCEINLINE constexpr size_t GetTypeHash(TStringView A) { return GetTypeHash(static_cast(A)); } + NODISCARD friend FORCEINLINE constexpr size_t GetTypeHash(TStringView A) { return GetTypeHash(static_cast(A)); } }; @@ -676,6 +676,8 @@ using FU16StringView = TStringView; using FU32StringView = TStringView; using FUnicodeStringView = TStringView; +// ReSharper disable CppInconsistentNaming + #define TEXT_VIEW(X) TStringView(TEXT(X)) #define WTEXT_VIEW(X) TStringView(WTEXT(X)) #define U8TEXT_VIEW(X) TStringView(U8TEXT(X)) @@ -685,6 +687,8 @@ using FUnicodeStringView = TStringView; #define LITERAL_VIEW(T, X) TStringView(LITERAL(T, X)) +// ReSharper restore CppInconsistentNaming + NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/Templates/Any.h b/Redcraft.Utility/Source/Public/Templates/Any.h index 25929f3..586107c 100644 --- a/Redcraft.Utility/Source/Public/Templates/Any.h +++ b/Redcraft.Utility/Source/Public/Templates/Any.h @@ -15,9 +15,9 @@ NAMESPACE_MODULE_BEGIN(Utility) // NOTE: In the STL, the assignment operation of the std::any type uses the copy-and-swap idiom // instead of directly calling the assignment operation of the contained value. -// The purpose of this is as follows: -// 1) the copy assignment might not exist. -// 2) the typical case is that the objects are different. +// The purpose of this is as follows: +// 1) the copy assignment might not exist. +// 2) the typical case is that the objects are different. // 3) it is less exception-safe // But we don't follow the the copy-and-swap idiom, because we assume that no function throws an exception. @@ -107,7 +107,7 @@ public: { EmplaceImpl(Forward(Args)...); } - + /** Constructs an object with initial content an object of type TDecay, direct-non-list-initialized from IL, Forward(Args).... */ template requires (NAMESPACE_PRIVATE::CFAnyPlaceable && CConstructibleFrom, initializer_list, Ts&&...>) FORCEINLINE explicit FAny(TInPlaceType, initializer_list IL, Ts&&... Args) @@ -244,23 +244,23 @@ public: && NAMESPACE_PRIVATE::CFAnyPlaceable && CConstructibleFrom, T&&>) FORCEINLINE FAny& operator=(T&& InValue) { - using DecayedType = TDecay; + using FDecayedType = TDecay; - if constexpr (CAssignableFrom) + if constexpr (CAssignableFrom) { - if (HoldsAlternative()) + if (HoldsAlternative()) { - GetValue() = Forward(InValue); + GetValue() = Forward(InValue); return *this; } } Destroy(); - EmplaceImpl(Forward(InValue)); + EmplaceImpl(Forward(InValue)); return *this; } - + /** Check if the contained value is equivalent to 'InValue'. */ template requires (!CSameAs> && NAMESPACE_PRIVATE::CFAnyPlaceable && CEqualityComparable) NODISCARD FORCEINLINE constexpr bool operator==(const T& InValue) const& @@ -352,12 +352,12 @@ public: Destroy(); Invalidate(); } - + /** Overloads the Swap algorithm for FAny. */ friend void Swap(FAny& A, FAny& B) { if (!A.IsValid() && !B.IsValid()) return; - + if (A.IsValid() && !B.IsValid()) { B = MoveTemp(A); @@ -524,7 +524,7 @@ private: default: check_no_entry(); return nullptr; } } - + FORCEINLINE const void* GetStorage() const { switch (GetRepresentation()) @@ -536,36 +536,36 @@ private: default: check_no_entry(); return nullptr; } } - + template void EmplaceImpl(Ts&&... Args) { - using DecayedType = TDecay; + using FDecayedType = TDecay; - TypeInfo = reinterpret_cast(&typeid(DecayedType)); + TypeInfo = reinterpret_cast(&typeid(FDecayedType)); - if constexpr (CEmpty && CTrivial) return; // ERepresentation::Empty + if constexpr (CEmpty && CTrivial) return; // ERepresentation::Empty - constexpr bool bIsTriviallyStorable = sizeof(DecayedType) <= sizeof(TrivialStorage.Internal) && alignof(DecayedType) <= alignof(FAny) && CTriviallyCopyable; - constexpr bool bIsSmallStorable = sizeof(DecayedType) <= sizeof( SmallStorage.Internal) && alignof(DecayedType) <= alignof(FAny); + constexpr bool bIsTriviallyStorable = sizeof(FDecayedType) <= sizeof(TrivialStorage.Internal) && alignof(FDecayedType) <= alignof(FAny) && CTriviallyCopyable; + constexpr bool bIsSmallStorable = sizeof(FDecayedType) <= sizeof( SmallStorage.Internal) && alignof(FDecayedType) <= alignof(FAny); - static constexpr const FRTTI SelectedRTTI(InPlaceType); + static constexpr const FRTTI SelectedRTTI(InPlaceType); if constexpr (bIsTriviallyStorable) { - new (&TrivialStorage.Internal) DecayedType(Forward(Args)...); + new (&TrivialStorage.Internal) FDecayedType(Forward(Args)...); TypeInfo |= static_cast(ERepresentation::Trivial); } else if constexpr (bIsSmallStorable) { - new (&SmallStorage.Internal) DecayedType(Forward(Args)...); + new (&SmallStorage.Internal) FDecayedType(Forward(Args)...); SmallStorage.RTTI = &SelectedRTTI; TypeInfo |= static_cast(ERepresentation::Small); } else { - BigStorage.External = Memory::Malloc(sizeof(DecayedType), alignof(DecayedType)); - new (BigStorage.External) DecayedType(Forward(Args)...); + BigStorage.External = Memory::Malloc(sizeof(FDecayedType), alignof(FDecayedType)); + new (BigStorage.External) FDecayedType(Forward(Args)...); BigStorage.RTTI = &SelectedRTTI; TypeInfo |= static_cast(ERepresentation::Big); } diff --git a/Redcraft.Utility/Source/Public/Templates/Atomic.h b/Redcraft.Utility/Source/Public/Templates/Atomic.h index 85384cb..61f3736 100644 --- a/Redcraft.Utility/Source/Public/Templates/Atomic.h +++ b/Redcraft.Utility/Source/Public/Templates/Atomic.h @@ -20,7 +20,7 @@ NAMESPACE_MODULE_BEGIN(Utility) * the values change in an order different from the order another thread wrote them. Indeed, * the apparent order of changes can even differ among multiple reader threads. Some similar effects * can occur even on uniprocessor systems due to compiler transformations allowed by the memory model. - * + * * @see https://en.cppreference.com/w/cpp/atomic/memory_order */ enum class EMemoryOrder : uint8 @@ -68,48 +68,48 @@ struct TAtomicImpl : FSingleton { protected: - using NativeAtomicType = TConditional, NAMESPACE_STD::atomic>; + using FNativeAtomic = TConditional, NAMESPACE_STD::atomic>; public: - using ValueType = T; + using FValueType = T; /** Indicates that the type is always lock-free */ - static constexpr bool bIsAlwaysLockFree = NativeAtomicType::is_always_lock_free; + static constexpr bool bIsAlwaysLockFree = FNativeAtomic::is_always_lock_free; /** Indicates the required alignment of an object to be referenced by TAtomicRef. */ static constexpr size_t RequiredAlignment = NAMESPACE_STD::atomic_ref::required_alignment; /** Constructs an atomic object. */ - FORCEINLINE constexpr TAtomicImpl() requires (!bIsRef) : NativeAtomic() { }; - FORCEINLINE constexpr TAtomicImpl(ValueType Desired) requires (!bIsRef) : NativeAtomic(Desired) { }; + FORCEINLINE constexpr TAtomicImpl() requires (!bIsRef) : NativeAtomic() { } + FORCEINLINE constexpr TAtomicImpl(FValueType Desired) requires (!bIsRef) : NativeAtomic(Desired) { } /** Constructs an atomic reference. */ - FORCEINLINE explicit TAtomicImpl(ValueType& Desired) requires (bIsRef) : NativeAtomic(Desired) { check(Memory::IsAligned(&Desired, RequiredAlignment)); }; - FORCEINLINE TAtomicImpl(TAtomicImpl& InValue) requires (bIsRef) : NativeAtomic(InValue) { }; + FORCEINLINE explicit TAtomicImpl(FValueType& Desired) requires (bIsRef) : NativeAtomic(Desired) { check(Memory::IsAligned(&Desired, RequiredAlignment)); } + FORCEINLINE TAtomicImpl(TAtomicImpl& InValue) requires (bIsRef) : NativeAtomic(InValue) { } /** Stores a value into an atomic object. */ - FORCEINLINE ValueType operator=(ValueType Desired) { return NativeAtomic = Desired; } - FORCEINLINE ValueType operator=(ValueType Desired) volatile requires (bIsAlwaysLockFree) { return NativeAtomic = Desired; } + FORCEINLINE FValueType operator=(FValueType Desired) { return NativeAtomic = Desired; } + FORCEINLINE FValueType operator=(FValueType Desired) volatile requires (bIsAlwaysLockFree) { return NativeAtomic = Desired; } /** Atomically replaces the value of the atomic object with a non-atomic argument. */ - FORCEINLINE void Store(ValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) { MEMORY_ORDER_CHECK(Order, 0x01 | 0x08 | 0x20); NativeAtomic.store(Desired, static_cast(Order)); } - FORCEINLINE void Store(ValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (bIsAlwaysLockFree) { MEMORY_ORDER_CHECK(Order, 0x01 | 0x08 | 0x20); NativeAtomic.store(Desired, static_cast(Order)); } - + FORCEINLINE void Store(FValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) { MEMORY_ORDER_CHECK(Order, 0x01 | 0x08 | 0x20); NativeAtomic.store(Desired, static_cast(Order)); } + FORCEINLINE void Store(FValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (bIsAlwaysLockFree) { MEMORY_ORDER_CHECK(Order, 0x01 | 0x08 | 0x20); NativeAtomic.store(Desired, static_cast(Order)); } + /** Atomically obtains the value of the atomic object. */ - NODISCARD FORCEINLINE ValueType Load(EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) const { MEMORY_ORDER_CHECK(Order, 0x01 | 0x02 | 0x04 | 0x20); return NativeAtomic.load(static_cast(Order)); } - NODISCARD FORCEINLINE ValueType Load(EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) const volatile requires (bIsAlwaysLockFree) { MEMORY_ORDER_CHECK(Order, 0x01 | 0x02 | 0x04 | 0x20); return NativeAtomic.load(static_cast(Order)); } - + NODISCARD FORCEINLINE FValueType Load(EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) const { MEMORY_ORDER_CHECK(Order, 0x01 | 0x02 | 0x04 | 0x20); return NativeAtomic.load(static_cast(Order)); } + NODISCARD FORCEINLINE FValueType Load(EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) const volatile requires (bIsAlwaysLockFree) { MEMORY_ORDER_CHECK(Order, 0x01 | 0x02 | 0x04 | 0x20); return NativeAtomic.load(static_cast(Order)); } + /** Loads a value from an atomic object. */ - NODISCARD FORCEINLINE operator ValueType() const { return static_cast(NativeAtomic); } - NODISCARD FORCEINLINE operator ValueType() const volatile requires (bIsAlwaysLockFree) { return static_cast(NativeAtomic); } - + NODISCARD FORCEINLINE operator FValueType() const { return static_cast(NativeAtomic); } + NODISCARD FORCEINLINE operator FValueType() const volatile requires (bIsAlwaysLockFree) { return static_cast(NativeAtomic); } + /** Atomically replaces the value of the atomic object and obtains the value held previously. */ - NODISCARD FORCEINLINE ValueType Exchange(ValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) { return NativeAtomic.exchange(Desired, static_cast(Order)); } - NODISCARD FORCEINLINE ValueType Exchange(ValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (bIsAlwaysLockFree) { return NativeAtomic.exchange(Desired, static_cast(Order)); } - + NODISCARD FORCEINLINE FValueType Exchange(FValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) { return NativeAtomic.exchange(Desired, static_cast(Order)); } + NODISCARD FORCEINLINE FValueType Exchange(FValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (bIsAlwaysLockFree) { return NativeAtomic.exchange(Desired, static_cast(Order)); } + /** Atomically compares the value of the atomic object with non-atomic argument and performs atomic exchange if equal or atomic load if not. */ - NODISCARD FORCEINLINE bool CompareExchange(ValueType& Expected, ValueType Desired, EMemoryOrder Success, EMemoryOrder Failure, bool bIsWeak = false) + NODISCARD FORCEINLINE bool CompareExchange(FValueType& Expected, FValueType Desired, EMemoryOrder Success, EMemoryOrder Failure, bool bIsWeak = false) { MEMORY_ORDER_CHECK(Failure, 0x01 | 0x02 | 0x04 | 0x20); if (bIsWeak) return NativeAtomic.compare_exchange_weak(Expected, Desired, static_cast(Success), static_cast(Failure)); @@ -117,7 +117,7 @@ public: } /** Atomically compares the value of the atomic object with non-atomic argument and performs atomic exchange if equal or atomic load if not. */ - NODISCARD FORCEINLINE bool CompareExchange(ValueType& Expected, ValueType Desired, EMemoryOrder Success, EMemoryOrder Failure, bool bIsWeak = false) volatile requires (bIsAlwaysLockFree) + NODISCARD FORCEINLINE bool CompareExchange(FValueType& Expected, FValueType Desired, EMemoryOrder Success, EMemoryOrder Failure, bool bIsWeak = false) volatile requires (bIsAlwaysLockFree) { MEMORY_ORDER_CHECK(Failure, 0x01 | 0x02 | 0x04 | 0x20); if (bIsWeak) return NativeAtomic.compare_exchange_weak(Expected, Desired, static_cast(Success), static_cast(Failure)); @@ -125,162 +125,162 @@ public: } /** Atomically compares the value of the atomic object with non-atomic argument and performs atomic exchange if equal or atomic load if not. */ - NODISCARD FORCEINLINE bool CompareExchange(ValueType& Expected, ValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent, bool bIsWeak = false) + NODISCARD FORCEINLINE bool CompareExchange(FValueType& Expected, FValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent, bool bIsWeak = false) { if (bIsWeak) return NativeAtomic.compare_exchange_weak(Expected, Desired, static_cast(Order)); else return NativeAtomic.compare_exchange_strong(Expected, Desired, static_cast(Order)); } /** Atomically compares the value of the atomic object with non-atomic argument and performs atomic exchange if equal or atomic load if not. */ - NODISCARD FORCEINLINE bool CompareExchange(ValueType& Expected, ValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent, bool bIsWeak = false) volatile requires (bIsAlwaysLockFree) + NODISCARD FORCEINLINE bool CompareExchange(FValueType& Expected, FValueType Desired, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent, bool bIsWeak = false) volatile requires (bIsAlwaysLockFree) { if (bIsWeak) return NativeAtomic.compare_exchange_weak(Expected, Desired, static_cast(Order)); else return NativeAtomic.compare_exchange_strong(Expected, Desired, static_cast(Order)); } - + /** Blocks the thread until notified and the atomic value changes. */ - FORCEINLINE void Wait(ValueType Old, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) { MEMORY_ORDER_CHECK(Order, 0x01 | 0x02 | 0x04 | 0x20); NativeAtomic.wait(Old, static_cast(Order)); } - FORCEINLINE void Wait(ValueType Old, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile { MEMORY_ORDER_CHECK(Order, 0x01 | 0x02 | 0x04 | 0x20); NativeAtomic.wait(Old, static_cast(Order)); } + FORCEINLINE void Wait(FValueType Old, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) { MEMORY_ORDER_CHECK(Order, 0x01 | 0x02 | 0x04 | 0x20); NativeAtomic.wait(Old, static_cast(Order)); } + FORCEINLINE void Wait(FValueType Old, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile { MEMORY_ORDER_CHECK(Order, 0x01 | 0x02 | 0x04 | 0x20); NativeAtomic.wait(Old, static_cast(Order)); } /** Notifies at least one or all threads blocked waiting on the atomic object. */ FORCEINLINE void Notify(bool bIsAll = false) { if (bIsAll) NativeAtomic.notify_all(); else NativeAtomic.notify_one(); } FORCEINLINE void Notify(bool bIsAll = false) volatile { if (bIsAll) NativeAtomic.notify_all(); else NativeAtomic.notify_one(); } /** Atomically executes the 'Func' on the value stored in the atomic object and obtains the value held previously. */ - template requires (CInvocableResult) - FORCEINLINE ValueType FetchFn(F&& Func, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) + template requires (CInvocableResult) + FORCEINLINE FValueType FetchFn(F&& Func, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) { - ValueType Temp(Load(EMemoryOrder::Relaxed)); + FValueType Temp(Load(EMemoryOrder::Relaxed)); // We do a weak read here because we require a loop. - while (!CompareExchange(Temp, InvokeResult(Forward(Func), Temp), Order, true)); + while (!CompareExchange(Temp, InvokeResult(Forward(Func), Temp), Order, true)); return Temp; } /** Atomically executes the 'Func' on the value stored in the atomic object and obtains the value held previously. */ - template requires (CInvocableResult && bIsAlwaysLockFree) - FORCEINLINE ValueType FetchFn(F&& Func, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile + template requires (CInvocableResult && bIsAlwaysLockFree) + FORCEINLINE FValueType FetchFn(F&& Func, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile { - ValueType Temp(Load(EMemoryOrder::Relaxed)); + FValueType Temp(Load(EMemoryOrder::Relaxed)); // We do a weak read here because we require a loop. - while (!CompareExchange(Temp, InvokeResult(Forward(Func), Temp), Order, true)); + while (!CompareExchange(Temp, InvokeResult(Forward(Func), Temp), Order, true)); return Temp; } /** Atomically adds the argument to the value stored in the atomic object and obtains the value held previously. */ - FORCEINLINE ValueType FetchAdd(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral || CFloatingPoint) { return NativeAtomic.fetch_add(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchAdd(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral || CFloatingPoint) && bIsAlwaysLockFree { return NativeAtomic.fetch_add(InValue, static_cast(Order)); } + FORCEINLINE FValueType FetchAdd(FValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral || CFloatingPoint) { return NativeAtomic.fetch_add(InValue, static_cast(Order)); } + FORCEINLINE FValueType FetchAdd(FValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral || CFloatingPoint) && bIsAlwaysLockFree { return NativeAtomic.fetch_add(InValue, static_cast(Order)); } /** Atomically adds the argument to the value stored in the atomic object and obtains the value held previously. */ - FORCEINLINE ValueType FetchAdd(ptrdiff InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CPointer ) { return NativeAtomic.fetch_add(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchAdd(ptrdiff InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CPointer && bIsAlwaysLockFree) { return NativeAtomic.fetch_add(InValue, static_cast(Order)); } + FORCEINLINE FValueType FetchAdd(ptrdiff InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CPointer ) { return NativeAtomic.fetch_add(InValue, static_cast(Order)); } + FORCEINLINE FValueType FetchAdd(ptrdiff InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CPointer && bIsAlwaysLockFree) { return NativeAtomic.fetch_add(InValue, static_cast(Order)); } /** Atomically subtracts the argument from the value stored in the atomic object and obtains the value held previously. */ - FORCEINLINE ValueType FetchSub(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral || CFloatingPoint) { return NativeAtomic.fetch_sub(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchSub(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral || CFloatingPoint) && bIsAlwaysLockFree { return NativeAtomic.fetch_sub(InValue, static_cast(Order)); } - + FORCEINLINE FValueType FetchSub(FValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral || CFloatingPoint) { return NativeAtomic.fetch_sub(InValue, static_cast(Order)); } + FORCEINLINE FValueType FetchSub(FValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral || CFloatingPoint) && bIsAlwaysLockFree { return NativeAtomic.fetch_sub(InValue, static_cast(Order)); } + /** Atomically subtracts the argument from the value stored in the atomic object and obtains the value held previously. */ - FORCEINLINE ValueType FetchSub(ptrdiff InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CPointer ) { return NativeAtomic.fetch_sub(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchSub(ptrdiff InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CPointer && bIsAlwaysLockFree) { return NativeAtomic.fetch_sub(InValue, static_cast(Order)); } + FORCEINLINE FValueType FetchSub(ptrdiff InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CPointer ) { return NativeAtomic.fetch_sub(InValue, static_cast(Order)); } + FORCEINLINE FValueType FetchSub(ptrdiff InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CPointer && bIsAlwaysLockFree) { return NativeAtomic.fetch_sub(InValue, static_cast(Order)); } /** Atomically multiples the argument from the value stored in the atomic object and obtains the value held previously. */ - FORCEINLINE ValueType FetchMul(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral || CFloatingPoint) { return FetchFn([InValue](ValueType Old) -> ValueType { return Old * InValue; }); } - FORCEINLINE ValueType FetchMul(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral || CFloatingPoint) && bIsAlwaysLockFree { return FetchFn([InValue](ValueType Old) -> ValueType { return Old * InValue; }); } + FORCEINLINE FValueType FetchMul(FValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral || CFloatingPoint) { return FetchFn([InValue](FValueType Old) -> FValueType { return Old * InValue; }); } + FORCEINLINE FValueType FetchMul(FValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral || CFloatingPoint) && bIsAlwaysLockFree { return FetchFn([InValue](FValueType Old) -> FValueType { return Old * InValue; }); } /** Atomically divides the argument from the value stored in the atomic object and obtains the value held previously. */ - FORCEINLINE ValueType FetchDiv(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral || CFloatingPoint) { return FetchFn([InValue](ValueType Old) -> ValueType { return Old / InValue; }); } - FORCEINLINE ValueType FetchDiv(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral || CFloatingPoint) && bIsAlwaysLockFree { return FetchFn([InValue](ValueType Old) -> ValueType { return Old / InValue; }); } + FORCEINLINE FValueType FetchDiv(FValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral || CFloatingPoint) { return FetchFn([InValue](FValueType Old) -> FValueType { return Old / InValue; }); } + FORCEINLINE FValueType FetchDiv(FValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral || CFloatingPoint) && bIsAlwaysLockFree { return FetchFn([InValue](FValueType Old) -> FValueType { return Old / InValue; }); } /** Atomically models the argument from the value stored in the atomic object and obtains the value held previously. */ - FORCEINLINE ValueType FetchMod(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral ) { return FetchFn([InValue](ValueType Old) -> ValueType { return Old % InValue; }); } - FORCEINLINE ValueType FetchMod(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral && bIsAlwaysLockFree) { return FetchFn([InValue](ValueType Old) -> ValueType { return Old % InValue; }); } - + FORCEINLINE FValueType FetchMod(FValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral ) { return FetchFn([InValue](FValueType Old) -> FValueType { return Old % InValue; }); } + FORCEINLINE FValueType FetchMod(FValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral && bIsAlwaysLockFree) { return FetchFn([InValue](FValueType Old) -> FValueType { return Old % InValue; }); } + /** Atomically performs bitwise AND between the argument and the value of the atomic object and obtains the value held previously. */ - FORCEINLINE ValueType FetchAnd(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral ) { return NativeAtomic.fetch_and(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchAnd(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral && bIsAlwaysLockFree) { return NativeAtomic.fetch_and(InValue, static_cast(Order)); } - + FORCEINLINE FValueType FetchAnd(FValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral ) { return NativeAtomic.fetch_and(InValue, static_cast(Order)); } + FORCEINLINE FValueType FetchAnd(FValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral && bIsAlwaysLockFree) { return NativeAtomic.fetch_and(InValue, static_cast(Order)); } + /** Atomically performs bitwise OR between the argument and the value of the atomic object and obtains the value held previously. */ - FORCEINLINE ValueType FetchOr(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral ) { return NativeAtomic.fetch_or(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchOr(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral && bIsAlwaysLockFree) { return NativeAtomic.fetch_or(InValue, static_cast(Order)); } - + FORCEINLINE FValueType FetchOr(FValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral ) { return NativeAtomic.fetch_or(InValue, static_cast(Order)); } + FORCEINLINE FValueType FetchOr(FValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral && bIsAlwaysLockFree) { return NativeAtomic.fetch_or(InValue, static_cast(Order)); } + /** Atomically performs bitwise XOR between the argument and the value of the atomic object and obtains the value held previously. */ - FORCEINLINE ValueType FetchXor(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral ) { return NativeAtomic.fetch_xor(InValue, static_cast(Order)); } - FORCEINLINE ValueType FetchXor(ValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral && bIsAlwaysLockFree) { return NativeAtomic.fetch_xor(InValue, static_cast(Order)); } - + FORCEINLINE FValueType FetchXor(FValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral ) { return NativeAtomic.fetch_xor(InValue, static_cast(Order)); } + FORCEINLINE FValueType FetchXor(FValueType InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral && bIsAlwaysLockFree) { return NativeAtomic.fetch_xor(InValue, static_cast(Order)); } + /** Atomically performs bitwise LSH between the argument and the value of the atomic object and obtains the value held previously. */ - FORCEINLINE ValueType FetchLsh(size_t InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral ) { return FetchFn([InValue](ValueType Old) -> ValueType { return Old << InValue; }); } - FORCEINLINE ValueType FetchLsh(size_t InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral && bIsAlwaysLockFree) { return FetchFn([InValue](ValueType Old) -> ValueType { return Old << InValue; }); } - + FORCEINLINE FValueType FetchLsh(size_t InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral ) { return FetchFn([InValue](FValueType Old) -> FValueType { return Old << InValue; }); } + FORCEINLINE FValueType FetchLsh(size_t InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral && bIsAlwaysLockFree) { return FetchFn([InValue](FValueType Old) -> FValueType { return Old << InValue; }); } + /** Atomically performs bitwise RSH between the argument and the value of the atomic object and obtains the value held previously. */ - FORCEINLINE ValueType FetchRsh(size_t InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral ) { return FetchFn([InValue](ValueType Old) -> ValueType { return Old >> InValue; }); } - FORCEINLINE ValueType FetchRsh(size_t InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral && bIsAlwaysLockFree) { return FetchFn([InValue](ValueType Old) -> ValueType { return Old >> InValue; }); } - - /** Increments the atomic value by one. */ - FORCEINLINE ValueType operator++() requires ((CIntegral || CPointer) ) { return ++NativeAtomic; } - FORCEINLINE ValueType operator++() volatile requires ((CIntegral || CPointer) && bIsAlwaysLockFree) { return ++NativeAtomic; } + FORCEINLINE FValueType FetchRsh(size_t InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) requires (CIntegral ) { return FetchFn([InValue](FValueType Old) -> FValueType { return Old >> InValue; }); } + FORCEINLINE FValueType FetchRsh(size_t InValue, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile requires (CIntegral && bIsAlwaysLockFree) { return FetchFn([InValue](FValueType Old) -> FValueType { return Old >> InValue; }); } /** Increments the atomic value by one. */ - FORCEINLINE ValueType operator++(int) requires ((CIntegral || CPointer) ) { return NativeAtomic++; } - FORCEINLINE ValueType operator++(int) volatile requires ((CIntegral || CPointer) && bIsAlwaysLockFree) { return NativeAtomic++; } + FORCEINLINE FValueType operator++() requires ((CIntegral || CPointer) ) { return ++NativeAtomic; } + FORCEINLINE FValueType operator++() volatile requires ((CIntegral || CPointer) && bIsAlwaysLockFree) { return ++NativeAtomic; } + + /** Increments the atomic value by one. */ + FORCEINLINE FValueType operator++(int) requires ((CIntegral || CPointer) ) { return NativeAtomic++; } + FORCEINLINE FValueType operator++(int) volatile requires ((CIntegral || CPointer) && bIsAlwaysLockFree) { return NativeAtomic++; } /** Decrements the atomic value by one. */ - FORCEINLINE ValueType operator--() requires ((CIntegral || CPointer) ) { return --NativeAtomic; } - FORCEINLINE ValueType operator--() volatile requires ((CIntegral || CPointer) && bIsAlwaysLockFree) { return --NativeAtomic; } + FORCEINLINE FValueType operator--() requires ((CIntegral || CPointer) ) { return --NativeAtomic; } + FORCEINLINE FValueType operator--() volatile requires ((CIntegral || CPointer) && bIsAlwaysLockFree) { return --NativeAtomic; } /** Decrements the atomic value by one. */ - FORCEINLINE ValueType operator--(int) requires ((CIntegral || CPointer) ) { return NativeAtomic--; } - FORCEINLINE ValueType operator--(int) volatile requires ((CIntegral || CPointer) && bIsAlwaysLockFree) { return NativeAtomic--; } - - /** Adds with the atomic value. */ - FORCEINLINE ValueType operator+=(ValueType InValue) requires ((CIntegral || CFloatingPoint) ) { return NativeAtomic += InValue; } - FORCEINLINE ValueType operator+=(ValueType InValue) volatile requires ((CIntegral || CFloatingPoint) && bIsAlwaysLockFree) { return NativeAtomic += InValue; } + FORCEINLINE FValueType operator--(int) requires ((CIntegral || CPointer) ) { return NativeAtomic--; } + FORCEINLINE FValueType operator--(int) volatile requires ((CIntegral || CPointer) && bIsAlwaysLockFree) { return NativeAtomic--; } /** Adds with the atomic value. */ - FORCEINLINE ValueType operator+=(ptrdiff InValue) requires (CPointer ) { return NativeAtomic += InValue; } - FORCEINLINE ValueType operator+=(ptrdiff InValue) volatile requires (CPointer && bIsAlwaysLockFree) { return NativeAtomic += InValue; } + FORCEINLINE FValueType operator+=(FValueType InValue) requires ((CIntegral || CFloatingPoint) ) { return NativeAtomic += InValue; } + FORCEINLINE FValueType operator+=(FValueType InValue) volatile requires ((CIntegral || CFloatingPoint) && bIsAlwaysLockFree) { return NativeAtomic += InValue; } + + /** Adds with the atomic value. */ + FORCEINLINE FValueType operator+=(ptrdiff InValue) requires (CPointer ) { return NativeAtomic += InValue; } + FORCEINLINE FValueType operator+=(ptrdiff InValue) volatile requires (CPointer && bIsAlwaysLockFree) { return NativeAtomic += InValue; } /** Subtracts with the atomic value. */ - FORCEINLINE ValueType operator-=(ValueType InValue) requires ((CIntegral || CFloatingPoint) ) { return NativeAtomic -= InValue; } - FORCEINLINE ValueType operator-=(ValueType InValue) volatile requires ((CIntegral || CFloatingPoint) && bIsAlwaysLockFree) { return NativeAtomic -= InValue; } + FORCEINLINE FValueType operator-=(FValueType InValue) requires ((CIntegral || CFloatingPoint) ) { return NativeAtomic -= InValue; } + FORCEINLINE FValueType operator-=(FValueType InValue) volatile requires ((CIntegral || CFloatingPoint) && bIsAlwaysLockFree) { return NativeAtomic -= InValue; } /** Subtracts with the atomic value. */ - FORCEINLINE ValueType operator-=(ptrdiff InValue) requires (CPointer ) { return NativeAtomic -= InValue; } - FORCEINLINE ValueType operator-=(ptrdiff InValue) volatile requires (CPointer && bIsAlwaysLockFree) { return NativeAtomic -= InValue; } + FORCEINLINE FValueType operator-=(ptrdiff InValue) requires (CPointer ) { return NativeAtomic -= InValue; } + FORCEINLINE FValueType operator-=(ptrdiff InValue) volatile requires (CPointer && bIsAlwaysLockFree) { return NativeAtomic -= InValue; } /** Multiples with the atomic value. */ - FORCEINLINE ValueType operator*=(ValueType InValue) requires ((CIntegral || CFloatingPoint) ) { return FetchMul(InValue) * InValue; } - FORCEINLINE ValueType operator*=(ValueType InValue) volatile requires ((CIntegral || CFloatingPoint) && bIsAlwaysLockFree) { return FetchMul(InValue) * InValue; } + FORCEINLINE FValueType operator*=(FValueType InValue) requires ((CIntegral || CFloatingPoint) ) { return FetchMul(InValue) * InValue; } + FORCEINLINE FValueType operator*=(FValueType InValue) volatile requires ((CIntegral || CFloatingPoint) && bIsAlwaysLockFree) { return FetchMul(InValue) * InValue; } /** Divides with the atomic value. */ - FORCEINLINE ValueType operator/=(ValueType InValue) requires ((CIntegral || CFloatingPoint) ) { return FetchDiv(InValue) / InValue; } - FORCEINLINE ValueType operator/=(ValueType InValue) volatile requires ((CIntegral || CFloatingPoint) && bIsAlwaysLockFree) { return FetchDiv(InValue) / InValue; } + FORCEINLINE FValueType operator/=(FValueType InValue) requires ((CIntegral || CFloatingPoint) ) { return FetchDiv(InValue) / InValue; } + FORCEINLINE FValueType operator/=(FValueType InValue) volatile requires ((CIntegral || CFloatingPoint) && bIsAlwaysLockFree) { return FetchDiv(InValue) / InValue; } /** Models with the atomic value. */ - FORCEINLINE ValueType operator%=(ValueType InValue) requires (CIntegral ) { return FetchMod(InValue) % InValue; } - FORCEINLINE ValueType operator%=(ValueType InValue) volatile requires (CIntegral && bIsAlwaysLockFree) { return FetchMod(InValue) % InValue; } + FORCEINLINE FValueType operator%=(FValueType InValue) requires (CIntegral ) { return FetchMod(InValue) % InValue; } + FORCEINLINE FValueType operator%=(FValueType InValue) volatile requires (CIntegral && bIsAlwaysLockFree) { return FetchMod(InValue) % InValue; } /** Performs bitwise AND with the atomic value. */ - FORCEINLINE ValueType operator&=(ValueType InValue) requires (CIntegral ) { return NativeAtomic &= InValue; } - FORCEINLINE ValueType operator&=(ValueType InValue) volatile requires (CIntegral && bIsAlwaysLockFree) { return NativeAtomic &= InValue; } + FORCEINLINE FValueType operator&=(FValueType InValue) requires (CIntegral ) { return NativeAtomic &= InValue; } + FORCEINLINE FValueType operator&=(FValueType InValue) volatile requires (CIntegral && bIsAlwaysLockFree) { return NativeAtomic &= InValue; } /** Performs bitwise OR with the atomic value. */ - FORCEINLINE ValueType operator|=(ValueType InValue) requires (CIntegral ) { return NativeAtomic |= InValue; } - FORCEINLINE ValueType operator|=(ValueType InValue) volatile requires (CIntegral && bIsAlwaysLockFree) { return NativeAtomic |= InValue; } + FORCEINLINE FValueType operator|=(FValueType InValue) requires (CIntegral ) { return NativeAtomic |= InValue; } + FORCEINLINE FValueType operator|=(FValueType InValue) volatile requires (CIntegral && bIsAlwaysLockFree) { return NativeAtomic |= InValue; } /** Performs bitwise XOR with the atomic value. */ - FORCEINLINE ValueType operator^=(ValueType InValue) requires (CIntegral ) { return NativeAtomic ^= InValue; } - FORCEINLINE ValueType operator^=(ValueType InValue) volatile requires (CIntegral && bIsAlwaysLockFree) { return NativeAtomic ^= InValue; } + FORCEINLINE FValueType operator^=(FValueType InValue) requires (CIntegral ) { return NativeAtomic ^= InValue; } + FORCEINLINE FValueType operator^=(FValueType InValue) volatile requires (CIntegral && bIsAlwaysLockFree) { return NativeAtomic ^= InValue; } /** Performs bitwise LSH with the atomic value. */ - FORCEINLINE ValueType operator<<=(size_t InValue) requires (CIntegral ) { return FetchLsh(InValue) << InValue; } - FORCEINLINE ValueType operator<<=(size_t InValue) volatile requires (CIntegral && bIsAlwaysLockFree) { return FetchLsh(InValue) << InValue; } + FORCEINLINE FValueType operator<<=(size_t InValue) requires (CIntegral ) { return FetchLsh(InValue) << InValue; } + FORCEINLINE FValueType operator<<=(size_t InValue) volatile requires (CIntegral && bIsAlwaysLockFree) { return FetchLsh(InValue) << InValue; } /** Performs bitwise RSH with the atomic value. */ - FORCEINLINE ValueType operator>>=(size_t InValue) requires (CIntegral ) { return FetchRsh(InValue) >> InValue; } - FORCEINLINE ValueType operator>>=(size_t InValue) volatile requires (CIntegral && bIsAlwaysLockFree) { return FetchRsh(InValue) >> InValue; } - + FORCEINLINE FValueType operator>>=(size_t InValue) requires (CIntegral ) { return FetchRsh(InValue) >> InValue; } + FORCEINLINE FValueType operator>>=(size_t InValue) volatile requires (CIntegral && bIsAlwaysLockFree) { return FetchRsh(InValue) >> InValue; } + protected: - NativeAtomicType NativeAtomic; + FNativeAtomic NativeAtomic; }; @@ -311,7 +311,7 @@ struct FAtomicFlag final : FSingleton public: /** Constructs an atomic flag. */ - FORCEINLINE constexpr FAtomicFlag() : NativeAtomic() { }; + FORCEINLINE constexpr FAtomicFlag() = default; /** Atomically sets flag to false. */ FORCEINLINE void Clear(EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) { MEMORY_ORDER_CHECK(Order, 0x01 | 0x08 | 0x20); NativeAtomic.clear(static_cast(Order)); } @@ -324,7 +324,7 @@ public: /** Atomically returns the value of the flag. */ NODISCARD FORCEINLINE bool Test(EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) const { MEMORY_ORDER_CHECK(Order, 0x01 | 0x02 | 0x04 | 0x20); return NativeAtomic.test(static_cast(Order)); } NODISCARD FORCEINLINE bool Test(EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) const volatile { MEMORY_ORDER_CHECK(Order, 0x01 | 0x02 | 0x04 | 0x20); return NativeAtomic.test(static_cast(Order)); } - + /** Blocks the thread until notified and the atomic value changes. */ FORCEINLINE void Wait(bool Old, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) const { MEMORY_ORDER_CHECK(Order, 0x01 | 0x02 | 0x04 | 0x20); const_cast(NativeAtomic).wait(Old, static_cast(Order)); } FORCEINLINE void Wait(bool Old, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) const volatile { MEMORY_ORDER_CHECK(Order, 0x01 | 0x02 | 0x04 | 0x20); const_cast(NativeAtomic).wait(Old, static_cast(Order)); } @@ -332,7 +332,7 @@ public: /** Notifies at least one or all threads blocked waiting on the atomic object. */ FORCEINLINE void Notify(bool bIsAll = false) { if (bIsAll) const_cast(NativeAtomic).notify_all(); else const_cast(NativeAtomic).notify_one(); } FORCEINLINE void Notify(bool bIsAll = false) volatile { if (bIsAll) const_cast(NativeAtomic).notify_all(); else const_cast(NativeAtomic).notify_one(); } - + private: NAMESPACE_STD::atomic_flag NativeAtomic; diff --git a/Redcraft.Utility/Source/Public/Templates/Function.h b/Redcraft.Utility/Source/Public/Templates/Function.h index 68ea927..b48934b 100644 --- a/Redcraft.Utility/Source/Public/Templates/Function.h +++ b/Redcraft.Utility/Source/Public/Templates/Function.h @@ -262,29 +262,29 @@ public: { Callable = InCallable; - using DecayedType = TDecay; + using FDecayedType = TDecay; - static constexpr const FRTTI SelectedRTTI(InPlaceType); + static constexpr const FRTTI SelectedRTTI(InPlaceType); RTTI = reinterpret_cast(&SelectedRTTI); - if constexpr (CEmpty && CTrivial) return; // ERepresentation::Empty + if constexpr (CEmpty && CTrivial) return; // ERepresentation::Empty - constexpr bool bIsTriviallyStorable = sizeof(DecayedType) <= sizeof(InternalStorage) && alignof(DecayedType) <= alignof(TFunctionStorage) && CTriviallyCopyable; - constexpr bool bIsSmallStorable = sizeof(DecayedType) <= sizeof(InternalStorage) && alignof(DecayedType) <= alignof(TFunctionStorage); + constexpr bool bIsTriviallyStorable = sizeof(FDecayedType) <= sizeof(InternalStorage) && alignof(FDecayedType) <= alignof(TFunctionStorage) && CTriviallyCopyable; + constexpr bool bIsSmallStorable = sizeof(FDecayedType) <= sizeof(InternalStorage) && alignof(FDecayedType) <= alignof(TFunctionStorage); if constexpr (bIsTriviallyStorable) { - new (&InternalStorage) DecayedType(Forward(Args)...); + new (&InternalStorage) FDecayedType(Forward(Args)...); RTTI |= static_cast(ERepresentation::Trivial); } else if constexpr (bIsSmallStorable) { - new (&InternalStorage) DecayedType(Forward(Args)...); + new (&InternalStorage) FDecayedType(Forward(Args)...); RTTI |= static_cast(ERepresentation::Small); } else { - ExternalStorage = new DecayedType(Forward(Args)...); + ExternalStorage = new FDecayedType(Forward(Args)...); RTTI |= static_cast(ERepresentation::Big); } @@ -446,12 +446,12 @@ template struct TIsInvocableSignature template struct TIsInvocableSignature : TBoolConstant> { }; template struct TFunctionInfo; -template struct TFunctionInfo { using Fn = Ret(Ts...); using CVRef = int; }; -template struct TFunctionInfo { using Fn = Ret(Ts...); using CVRef = int&; }; -template struct TFunctionInfo { using Fn = Ret(Ts...); using CVRef = int&&; }; -template struct TFunctionInfo { using Fn = Ret(Ts...); using CVRef = const int; }; -template struct TFunctionInfo { using Fn = Ret(Ts...); using CVRef = const int&; }; -template struct TFunctionInfo { using Fn = Ret(Ts...); using CVRef = const int&&; }; +template struct TFunctionInfo { using FFn = Ret(Ts...); using FCVRef = int; }; +template struct TFunctionInfo { using FFn = Ret(Ts...); using FCVRef = int&; }; +template struct TFunctionInfo { using FFn = Ret(Ts...); using FCVRef = int&&; }; +template struct TFunctionInfo { using FFn = Ret(Ts...); using FCVRef = const int; }; +template struct TFunctionInfo { using FFn = Ret(Ts...); using FCVRef = const int&; }; +template struct TFunctionInfo { using FFn = Ret(Ts...); using FCVRef = const int&&; }; template class TFunctionImpl; @@ -460,8 +460,8 @@ class TFunctionImpl { public: - using ResultType = Ret; - using ArgumentType = TTypeSequence; + using FResultType = Ret; + using FArgumentType = TTypeSequence; FORCEINLINE constexpr TFunctionImpl() = default; FORCEINLINE constexpr TFunctionImpl(const TFunctionImpl&) = default; @@ -471,12 +471,12 @@ public: FORCEINLINE constexpr ~TFunctionImpl() = default; /** Invokes the stored callable function target with the parameters args. */ - FORCEINLINE ResultType operator()(Ts... Args) requires (CSameAs) { return CallImpl(Forward(Args)...); } - FORCEINLINE ResultType operator()(Ts... Args) & requires (CSameAs) { return CallImpl(Forward(Args)...); } - FORCEINLINE ResultType operator()(Ts... Args) && requires (CSameAs) { return CallImpl(Forward(Args)...); } - FORCEINLINE ResultType operator()(Ts... Args) const requires (CSameAs) { return CallImpl(Forward(Args)...); } - FORCEINLINE ResultType operator()(Ts... Args) const& requires (CSameAs) { return CallImpl(Forward(Args)...); } - FORCEINLINE ResultType operator()(Ts... Args) const&& requires (CSameAs) { return CallImpl(Forward(Args)...); } + FORCEINLINE FResultType operator()(Ts... Args) requires (CSameAs) { return CallImpl(Forward(Args)...); } + FORCEINLINE FResultType operator()(Ts... Args) & requires (CSameAs) { return CallImpl(Forward(Args)...); } + FORCEINLINE FResultType operator()(Ts... Args) && requires (CSameAs) { return CallImpl(Forward(Args)...); } + FORCEINLINE FResultType operator()(Ts... Args) const requires (CSameAs) { return CallImpl(Forward(Args)...); } + FORCEINLINE FResultType operator()(Ts... Args) const& requires (CSameAs) { return CallImpl(Forward(Args)...); } + FORCEINLINE FResultType operator()(Ts... Args) const&& requires (CSameAs) { return CallImpl(Forward(Args)...); } /** @return false if instance stores a callable function target, true otherwise. */ NODISCARD FORCEINLINE constexpr bool operator==(nullptr_t) const& requires (!bIsRef) { return !IsValid(); } @@ -487,14 +487,14 @@ public: private: - using CallableType = ResultType(*)(uintptr, Ts&&...); + using FCallableType = FResultType(*)(uintptr, Ts&&...); TFunctionStorage Storage; - FORCEINLINE ResultType CallImpl(Ts&&... Args) const + FORCEINLINE FResultType CallImpl(Ts&&... Args) const { checkf(Storage.IsValid(), TEXT("Attempting to call an unbound TFunction!")); - CallableType Callable = reinterpret_cast(Storage.GetCallable()); + FCallableType Callable = reinterpret_cast(Storage.GetCallable()); return Callable(Storage.GetValuePtr(), Forward(Args)...); } @@ -510,26 +510,26 @@ protected: template FORCEINLINE constexpr TDecay& Emplace(Us&&... Args) { - using DecayedType = TDecay; + using FDecayedType = TDecay; // This add a l-value reference to a non-reference type, while preserving the r-value reference. - using ObjectType = TCopyCVRef; - using InvokeType = TConditional, ObjectType, ObjectType&>; + using FObjectType = TCopyCVRef; + using FInvokeType = TConditional, FObjectType, FObjectType&>; - CallableType Callable = [](uintptr ObjectPtr, Ts&&... Args) -> ResultType + FCallableType Callable = [](uintptr ObjectPtr, Ts&&... Args) -> FResultType { - return InvokeResult( - static_cast(*reinterpret_cast(ObjectPtr)), + return InvokeResult( + static_cast(*reinterpret_cast(ObjectPtr)), Forward(Args)... ); }; - Storage.template Emplace( + Storage.template Emplace( reinterpret_cast(Callable), Forward(Args)... ); - return *reinterpret_cast(Storage.GetValuePtr()); + return *reinterpret_cast(Storage.GetValuePtr()); } friend FORCEINLINE constexpr void Swap(TFunctionImpl& A, TFunctionImpl& B) requires (!bIsRef) { Swap(A.Storage, B.Storage); } @@ -552,15 +552,15 @@ NAMESPACE_PRIVATE_END template class TFunctionRef final : public NAMESPACE_PRIVATE::TFunctionImpl< - typename NAMESPACE_PRIVATE::TFunctionInfo::Fn, - typename NAMESPACE_PRIVATE::TFunctionInfo::CVRef, + typename NAMESPACE_PRIVATE::TFunctionInfo::FFn, + typename NAMESPACE_PRIVATE::TFunctionInfo::FCVRef, true> { private: - using Impl = NAMESPACE_PRIVATE::TFunctionImpl< - typename NAMESPACE_PRIVATE::TFunctionInfo::Fn, - typename NAMESPACE_PRIVATE::TFunctionInfo::CVRef, + using FImpl = NAMESPACE_PRIVATE::TFunctionImpl< + typename NAMESPACE_PRIVATE::TFunctionInfo::FFn, + typename NAMESPACE_PRIVATE::TFunctionInfo::FCVRef, true>; public: @@ -585,7 +585,7 @@ public: 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)); + FImpl::template Emplace(Forward(InValue)); } template @@ -602,21 +602,21 @@ public: template class TFunction final : public NAMESPACE_PRIVATE::TFunctionImpl< - typename NAMESPACE_PRIVATE::TFunctionInfo::Fn, - typename NAMESPACE_PRIVATE::TFunctionInfo::CVRef, + typename NAMESPACE_PRIVATE::TFunctionInfo::FFn, + typename NAMESPACE_PRIVATE::TFunctionInfo::FCVRef, false, false> { private: - using Impl = NAMESPACE_PRIVATE::TFunctionImpl< - typename NAMESPACE_PRIVATE::TFunctionInfo::Fn, - typename NAMESPACE_PRIVATE::TFunctionInfo::CVRef, + using FImpl = NAMESPACE_PRIVATE::TFunctionImpl< + typename NAMESPACE_PRIVATE::TFunctionInfo::FFn, + typename NAMESPACE_PRIVATE::TFunctionInfo::FCVRef, false, false>; public: /** Default constructor. */ - FORCEINLINE constexpr TFunction(nullptr_t = nullptr) { Impl::Invalidate(); } + FORCEINLINE constexpr TFunction(nullptr_t = nullptr) { FImpl::Invalidate(); } FORCEINLINE TFunction(const TFunction&) = default; FORCEINLINE TFunction(TFunction&&) = default; @@ -634,8 +634,8 @@ public: && NAMESPACE_PRIVATE::TIsInvocableSignature>::Value) FORCEINLINE TFunction(T&& InValue) { - if (!NAMESPACE_PRIVATE::FunctionIsBound(InValue)) Impl::Invalidate(); - else Impl::template Emplace(Forward(InValue)); + if (!NAMESPACE_PRIVATE::FunctionIsBound(InValue)) FImpl::Invalidate(); + else FImpl::template Emplace(Forward(InValue)); } /** @@ -647,7 +647,7 @@ public: && CMoveConstructible> && CDestructible>) FORCEINLINE explicit TFunction(TInPlaceType, Ts&&... Args) { - Impl::template Emplace(Forward(Args)...); + FImpl::template Emplace(Forward(Args)...); } /** @@ -659,7 +659,7 @@ public: && CMoveConstructible> && CDestructible>) FORCEINLINE explicit TFunction(TInPlaceType, initializer_list IL, Ts&&... Args) { - Impl::template Emplace(IL, Forward(Args)...); + FImpl::template Emplace(IL, Forward(Args)...); } /** Removes any bound callable from the TFunction, restoring it to the default empty state. */ @@ -692,8 +692,8 @@ public: && CMoveConstructible> && CDestructible>) FORCEINLINE TDecay& Emplace(Ts&&... Args) { - Impl::Destroy(); - return Impl::template Emplace(Forward(Args)...); + FImpl::Destroy(); + return FImpl::template Emplace(Forward(Args)...); } /** @@ -710,15 +710,15 @@ public: && CMoveConstructible> && CDestructible>) FORCEINLINE TDecay& Emplace(initializer_list IL, Ts&&... Args) { - Impl::Destroy(); - return Impl::template Emplace(IL, Forward(Args)...); + FImpl::Destroy(); + return FImpl::template Emplace(IL, Forward(Args)...); } /** Removes any bound callable from the TFunction, restoring it to the default empty state. */ - FORCEINLINE constexpr void Reset() { Impl::Destroy(); Impl::Invalidate(); } + FORCEINLINE constexpr void Reset() { FImpl::Destroy(); FImpl::Invalidate(); } /** Overloads the Swap algorithm for TFunction. */ - friend FORCEINLINE constexpr void Swap(TFunction& A, TFunction& B) { Swap(static_cast(A), static_cast(B)); } + friend FORCEINLINE constexpr void Swap(TFunction& A, TFunction& B) { Swap(static_cast(A), static_cast(B)); } }; @@ -731,21 +731,21 @@ public: template class TUniqueFunction final : public NAMESPACE_PRIVATE::TFunctionImpl< - typename NAMESPACE_PRIVATE::TFunctionInfo::Fn, - typename NAMESPACE_PRIVATE::TFunctionInfo::CVRef, + typename NAMESPACE_PRIVATE::TFunctionInfo::FFn, + typename NAMESPACE_PRIVATE::TFunctionInfo::FCVRef, false, true> { private: - using Impl = NAMESPACE_PRIVATE::TFunctionImpl< - typename NAMESPACE_PRIVATE::TFunctionInfo::Fn, - typename NAMESPACE_PRIVATE::TFunctionInfo::CVRef, + using FImpl = NAMESPACE_PRIVATE::TFunctionImpl< + typename NAMESPACE_PRIVATE::TFunctionInfo::FFn, + typename NAMESPACE_PRIVATE::TFunctionInfo::FCVRef, false, true>; public: /** Default constructor. */ - FORCEINLINE constexpr TUniqueFunction(nullptr_t = nullptr) { Impl::Invalidate(); } + FORCEINLINE constexpr TUniqueFunction(nullptr_t = nullptr) { FImpl::Invalidate(); } FORCEINLINE TUniqueFunction(const TUniqueFunction&) = delete; FORCEINLINE TUniqueFunction(TUniqueFunction&&) = default; @@ -788,8 +788,8 @@ public: && NAMESPACE_PRIVATE::TIsInvocableSignature>::Value) FORCEINLINE TUniqueFunction(T&& InValue) { - if (!NAMESPACE_PRIVATE::FunctionIsBound(InValue)) Impl::Invalidate(); - else Impl::template Emplace(Forward(InValue)); + if (!NAMESPACE_PRIVATE::FunctionIsBound(InValue)) FImpl::Invalidate(); + else FImpl::template Emplace(Forward(InValue)); } /** @@ -800,7 +800,7 @@ public: && CConstructibleFrom, Ts...> && CMoveConstructible> && CDestructible>) FORCEINLINE explicit TUniqueFunction(TInPlaceType, Ts&&... Args) { - Impl::template Emplace(Forward(Args)...); + FImpl::template Emplace(Forward(Args)...); } /** @@ -811,11 +811,11 @@ public: && CConstructibleFrom, initializer_list, Ts...> && CMoveConstructible> && CDestructible>) FORCEINLINE explicit TUniqueFunction(TInPlaceType, initializer_list IL, Ts&&... Args) { - Impl::template Emplace(IL, Forward(Args)...); + FImpl::template Emplace(IL, Forward(Args)...); } /** Removes any bound callable from the TUniqueFunction, restoring it to the default empty state. */ - FORCEINLINE constexpr TUniqueFunction& operator=(nullptr_t) { Impl::Destroy(); Impl::Invalidate(); return *this; } + FORCEINLINE constexpr TUniqueFunction& operator=(nullptr_t) { FImpl::Destroy(); FImpl::Invalidate(); return *this; } template requires (NAMESPACE_PRIVATE::TIsInvocableSignature>::Value && !CTFunctionRef> && !CTFunction> && !CTUniqueFunction> @@ -841,9 +841,9 @@ public: && CConstructibleFrom, Ts...> && CMoveConstructible> && CDestructible>) FORCEINLINE TDecay& Emplace(Ts&&... Args) { - Impl::Destroy(); - using DecayedType = TDecay; - return Impl::template Emplace(Forward(Args)...); + FImpl::Destroy(); + + return FImpl::template Emplace(Forward(Args)...); } /** @@ -859,16 +859,16 @@ public: && CConstructibleFrom, initializer_list, Ts...> && CMoveConstructible> && CDestructible>) FORCEINLINE TDecay& Emplace(initializer_list IL, Ts&&... Args) { - Impl::Destroy(); - using DecayedType = TDecay; - return Impl::template Emplace(IL, Forward(Args)...); + FImpl::Destroy(); + + return FImpl::template Emplace(IL, Forward(Args)...); } /** Removes any bound callable from the TUniqueFunction, restoring it to the default empty state. */ - FORCEINLINE constexpr void Reset() { Impl::Destroy(); Impl::Invalidate(); } + FORCEINLINE constexpr void Reset() { FImpl::Destroy(); FImpl::Invalidate(); } /** Overloads the Swap algorithm for TUniqueFunction. */ - friend FORCEINLINE constexpr void Swap(TUniqueFunction& A, TUniqueFunction& B) { Swap(static_cast(A), static_cast(B)); } + friend FORCEINLINE constexpr void Swap(TUniqueFunction& A, TUniqueFunction& B) { Swap(static_cast(A), static_cast(B)); } }; diff --git a/Redcraft.Utility/Source/Public/Templates/Invoke.h b/Redcraft.Utility/Source/Public/Templates/Invoke.h index 9829e64..fba28ac 100644 --- a/Redcraft.Utility/Source/Public/Templates/Invoke.h +++ b/Redcraft.Utility/Source/Public/Templates/Invoke.h @@ -10,7 +10,7 @@ NAMESPACE_MODULE_BEGIN(Utility) NAMESPACE_PRIVATE_BEGIN -struct InvokeFunction +struct FInvokeFunction { template static auto Invoke(F&& Object, Ts&&... Args) @@ -20,7 +20,7 @@ struct InvokeFunction } }; -struct InvokeMemberFunction +struct FInvokeMemberFunction { template static auto Invoke(F&& Func, ObjectType&& Object, Ts&&... Args) @@ -37,7 +37,7 @@ struct InvokeMemberFunction } }; -struct InvokeMemberObject +struct FInvokeMemberObject { template static auto Invoke(F&& Func, ObjectType&& Object) @@ -59,34 +59,34 @@ template , bool IsMemberFunction = CMemberFunctionPointer, bool IsMemberObject = CMemberObjectPointer> - struct InvokeMember; +struct FInvokeMember; template -struct InvokeMember : InvokeMemberFunction { }; +struct FInvokeMember : FInvokeMemberFunction { }; template -struct InvokeMember : InvokeMemberObject { }; +struct FInvokeMember : FInvokeMemberObject { }; template -struct InvokeMember : InvokeFunction { }; +struct FInvokeMember : FInvokeFunction { }; template -struct InvokeImpl; +struct FInvokeImpl; template -struct InvokeImpl : InvokeFunction { }; +struct FInvokeImpl : FInvokeFunction { }; template -struct InvokeImpl : InvokeMember { }; +struct FInvokeImpl : FInvokeMember { }; NAMESPACE_PRIVATE_END /** Invoke the Callable object f with the parameters args. */ template requires (CInvocable) FORCEINLINE constexpr auto Invoke(F&& Func, Ts&&... Args) - -> decltype(NAMESPACE_PRIVATE::InvokeImpl::Invoke(Forward(Func), Forward(Args)...)) + -> decltype(NAMESPACE_PRIVATE::FInvokeImpl::Invoke(Forward(Func), Forward(Args)...)) { - return NAMESPACE_PRIVATE::InvokeImpl::Invoke(Forward(Func), Forward(Args)...); + return NAMESPACE_PRIVATE::FInvokeImpl::Invoke(Forward(Func), Forward(Args)...); } /** Invoke the Callable object f with the parameters args. */ diff --git a/Redcraft.Utility/Source/Public/Templates/Meta.h b/Redcraft.Utility/Source/Public/Templates/Meta.h index 2e9e4f7..01a6986 100644 --- a/Redcraft.Utility/Source/Public/Templates/Meta.h +++ b/Redcraft.Utility/Source/Public/Templates/Meta.h @@ -12,7 +12,7 @@ NAMESPACE_MODULE_BEGIN(Utility) template struct TIntegerSequence { - using ValueType = T; + using FValueType = T; FORCEINLINE static constexpr size_t Num() { return sizeof...(Ints); } FORCEINLINE static constexpr const T* GetData() { return NAMESPACE_REDCRAFT::GetData({ Ints... }); } }; @@ -24,7 +24,7 @@ NAMESPACE_PRIVATE_BEGIN template struct TMakeIntegerSequenceImpl { - using Type = typename __make_integer_seq; + using FType = typename __make_integer_seq; }; #elif __has_builtin(__make_integer_seq) @@ -32,7 +32,7 @@ struct TMakeIntegerSequenceImpl template struct TMakeIntegerSequenceImpl { - using Type = typename __make_integer_seq; + using FType = typename __make_integer_seq; }; #else @@ -40,13 +40,13 @@ struct TMakeIntegerSequenceImpl template struct TMakeIntegerSequenceImpl { - using Type = typename TMakeIntegerSequenceImpl::Type; + using FType = typename TMakeIntegerSequenceImpl::FType; }; template struct TMakeIntegerSequenceImpl<0, T, Ints...> { - using Type = TIntegerSequence; + using FType = TIntegerSequence; }; #endif @@ -57,7 +57,7 @@ template using TIndexSequence = TIntegerSequence; template -using TMakeIntegerSequence = typename NAMESPACE_PRIVATE::TMakeIntegerSequenceImpl::Type; +using TMakeIntegerSequence = typename NAMESPACE_PRIVATE::TMakeIntegerSequenceImpl::FType; template using TMakeIndexSequence = TMakeIntegerSequence; @@ -103,7 +103,7 @@ struct TFrontImpl; template struct TFrontImpl> { - using Type = T; + using FType = T; }; template @@ -112,7 +112,7 @@ struct TPopImpl; template struct TPopImpl> { - using Type = TTypeSequence; + using FType = TTypeSequence; }; template @@ -121,19 +121,19 @@ struct TPushImpl; template struct TPushImpl> { - using Type = TTypeSequence; + using FType = TTypeSequence; }; NAMESPACE_PRIVATE_END template -using TFront = typename NAMESPACE_PRIVATE::TFrontImpl::Type; +using TFront = typename NAMESPACE_PRIVATE::TFrontImpl::FType; template -using TPop = typename NAMESPACE_PRIVATE::TPopImpl::Type; +using TPop = typename NAMESPACE_PRIVATE::TPopImpl::FType; template -using TPush = typename NAMESPACE_PRIVATE::TPushImpl::Type; +using TPush = typename NAMESPACE_PRIVATE::TPushImpl::FType; NAMESPACE_PRIVATE_BEGIN @@ -194,19 +194,19 @@ struct TIndexAssert template struct TTypeImpl { - using Type = typename TTypeImpl>::Type; + using FType = typename TTypeImpl>::FType; }; template struct TTypeImpl<0, TSequence> { - using Type = TFront; + using FType = TFront; }; template struct TTypeImpl { - using Type = void; + using FType = void; }; template @@ -214,7 +214,7 @@ struct TTypeAssert { static_assert(I < TSizeImpl::Value, "I is invalid index in type sequence"); static constexpr size_t SafeIndex = I < TSizeImpl::Value ? I : INDEX_NONE; - using Type = TCopyCV::Type>; + using FType = TCopyCV::FType>; }; NAMESPACE_PRIVATE_END @@ -226,29 +226,29 @@ template inline constexpr size_t TIndex = NAMESPACE_PRIVATE::TIndexAssert::Value; template -using TType = typename NAMESPACE_PRIVATE::TTypeAssert::Type; +using TType = typename NAMESPACE_PRIVATE::TTypeAssert::FType; NAMESPACE_PRIVATE_BEGIN template struct TUniqueTypeSequenceImpl { - using FrontType = TFront; - using NextSequence = TPop; - using NextUniqueSequence = typename TUniqueTypeSequenceImpl::Type; - using Type = TConditional, TPush, NextUniqueSequence>; + using FFrontType = TFront; + using FNextSequence = TPop; + using FNextUniqueSequence = typename TUniqueTypeSequenceImpl::FType; + using FType = TConditional, TPush, FNextUniqueSequence>; }; template <> struct TUniqueTypeSequenceImpl> { - using Type = TTypeSequence<>; + using FType = TTypeSequence<>; }; NAMESPACE_PRIVATE_END template -using TUniqueTypeSequence = typename NAMESPACE_PRIVATE::TUniqueTypeSequenceImpl::Type; +using TUniqueTypeSequence = typename NAMESPACE_PRIVATE::TUniqueTypeSequenceImpl::FType; NAMESPACE_PRIVATE_BEGIN diff --git a/Redcraft.Utility/Source/Public/Templates/Optional.h b/Redcraft.Utility/Source/Public/Templates/Optional.h index 4aad94e..23d60ae 100644 --- a/Redcraft.Utility/Source/Public/Templates/Optional.h +++ b/Redcraft.Utility/Source/Public/Templates/Optional.h @@ -45,9 +45,9 @@ class TOptional final { public: - using ValueType = T; + using FValueType = T; - static_assert(!CReference); + static_assert(!CReference); /** Constructs an object that does not contain a value. */ FORCEINLINE constexpr TOptional() : bIsValid(false) { } @@ -67,7 +67,7 @@ public: FORCEINLINE constexpr explicit TOptional(FInPlace, Ts&&... Args) : bIsValid(true) { - new (&Value) ValueType(Forward(Args)...); + new (&Value) FValueType(Forward(Args)...); } /** Constructs an object with initial content an object, direct-non-list-initialized from IL, Forward(Args).... */ @@ -75,7 +75,7 @@ public: FORCEINLINE constexpr explicit TOptional(FInPlace, initializer_list IL, Ts&&... Args) : bIsValid(true) { - new (&Value) ValueType(IL, Forward(Args)...); + new (&Value) FValueType(IL, Forward(Args)...); } /** Copies content of other into a new instance. */ @@ -85,7 +85,7 @@ public: FORCEINLINE constexpr TOptional(const TOptional& InValue) requires (CCopyConstructible && !CTriviallyCopyConstructible) : bIsValid(InValue.IsValid()) { - if (InValue.IsValid()) new (&Value) ValueType(InValue.GetValue()); + if (InValue.IsValid()) new (&Value) FValueType(InValue.GetValue()); } /** Moves content of other into a new instance. */ @@ -95,7 +95,7 @@ public: FORCEINLINE constexpr TOptional(TOptional&& InValue) requires (CMoveConstructible && !CTriviallyMoveConstructible) : bIsValid(InValue.IsValid()) { - if (InValue.IsValid()) new (&Value) ValueType(MoveTemp(InValue.GetValue())); + if (InValue.IsValid()) new (&Value) FValueType(MoveTemp(InValue.GetValue())); } /** Converting copy constructor. */ @@ -103,7 +103,7 @@ public: FORCEINLINE constexpr explicit (!CConvertibleTo) TOptional(const TOptional& InValue) : bIsValid(InValue.IsValid()) { - if (InValue.IsValid()) new (&Value) ValueType(InValue.GetValue()); + if (InValue.IsValid()) new (&Value) FValueType(InValue.GetValue()); } /** Converting move constructor. */ @@ -111,7 +111,7 @@ public: FORCEINLINE constexpr explicit (!CConvertibleTo) TOptional(TOptional&& InValue) : bIsValid(InValue.IsValid()) { - if (InValue.IsValid()) new (&Value) ValueType(MoveTemp(InValue.GetValue())); + if (InValue.IsValid()) new (&Value) FValueType(MoveTemp(InValue.GetValue())); } /** Destroys the contained object, if any, as if by a call to Reset(). */ @@ -141,7 +141,7 @@ public: if (IsValid()) GetValue() = InValue.GetValue(); else { - new (&Value) ValueType(InValue.GetValue()); + new (&Value) FValueType(InValue.GetValue()); bIsValid = true; } @@ -166,7 +166,7 @@ public: if (IsValid()) GetValue() = MoveTemp(InValue.GetValue()); else { - new (&Value) ValueType(MoveTemp(InValue.GetValue())); + new (&Value) FValueType(MoveTemp(InValue.GetValue())); bIsValid = true; } @@ -187,7 +187,7 @@ public: if (IsValid()) GetValue() = InValue.GetValue(); else { - new (&Value) ValueType(InValue.GetValue()); + new (&Value) FValueType(InValue.GetValue()); bIsValid = true; } @@ -208,7 +208,7 @@ public: if (IsValid()) GetValue() = MoveTemp(InValue.GetValue()); else { - new (&Value) ValueType(MoveTemp(InValue.GetValue())); + new (&Value) FValueType(MoveTemp(InValue.GetValue())); bIsValid = true; } @@ -222,7 +222,7 @@ public: if (IsValid()) GetValue() = Forward(InValue); else { - new (&Value) ValueType(Forward(InValue)); + new (&Value) FValueType(Forward(InValue)); bIsValid = true; } @@ -278,7 +278,7 @@ public: { Reset(); - T* Result = new (&Value) ValueType(Forward(Args)...); + T* Result = new (&Value) FValueType(Forward(Args)...); bIsValid = true; return *Result; @@ -298,7 +298,7 @@ public: { Reset(); - T* Result = new (&Value) ValueType(IL, Forward(Args)...); + T* Result = new (&Value) FValueType(IL, Forward(Args)...); bIsValid = true; return *Result; @@ -335,7 +335,7 @@ public: { bIsValid = false; - reinterpret_cast(&Value)->~ValueType(); + reinterpret_cast(&Value)->~FValueType(); } } @@ -380,9 +380,9 @@ class TOptional final { public: - using ValueType = TRemoveReference; + using FValueType = TRemoveReference; - static_assert(!CReference); + static_assert(!CReference); /** Constructs an object that does not contain a reference. */ FORCEINLINE constexpr TOptional() : Ptr(nullptr) { } @@ -408,13 +408,13 @@ public: { } /** Converting constructor. */ - template requires (!CConst && CConstructibleFrom && NAMESPACE_PRIVATE::CTOptionalAllowUnwrappable) + template requires (!CConst && CConstructibleFrom && NAMESPACE_PRIVATE::CTOptionalAllowUnwrappable) FORCEINLINE constexpr explicit (!CConvertibleTo) TOptional(TOptional& InValue) : Ptr(InValue.IsValid() ? AddressOf(static_cast(InValue.GetValue())) : nullptr) { } /** Converting constructor. */ - template requires (CConst && CConstructibleFrom && NAMESPACE_PRIVATE::CTOptionalAllowUnwrappable) + template requires (CConst && CConstructibleFrom && NAMESPACE_PRIVATE::CTOptionalAllowUnwrappable) FORCEINLINE constexpr explicit (!CConvertibleTo) TOptional(const TOptional& InValue) : Ptr(InValue.IsValid() ? AddressOf(static_cast(InValue.GetValue())) : nullptr) { } @@ -492,7 +492,7 @@ public: private: - ValueType* Ptr; + FValueType* Ptr; }; diff --git a/Redcraft.Utility/Source/Public/Templates/PropagateConst.h b/Redcraft.Utility/Source/Public/Templates/PropagateConst.h index 9b88039..dd6a40b 100644 --- a/Redcraft.Utility/Source/Public/Templates/PropagateConst.h +++ b/Redcraft.Utility/Source/Public/Templates/PropagateConst.h @@ -24,7 +24,7 @@ template concept CTPropagateConst = NAMESPACE_PRIVATE::TIsTPropagateConst>::Value; /** - * TPropagateConst is a const-propagating wrapper for pointers and pointer-like objects. + * TPropagateConst is a const-propagating wrapper for pointers and pointer-like objects. * It treats the wrapped pointer as a pointer to const when accessed through a const access path, hence the name. */ template requires (TPointerTraits::bIsPointer) @@ -32,7 +32,7 @@ class TPropagateConst final { public: - using ElementType = TPointerTraits::ElementType; + using FElementType = TPointerTraits::FElementType; /** Constructs an TPropagateConst, default-initializing underlying pointer. */ FORCEINLINE constexpr TPropagateConst() = default; @@ -105,26 +105,26 @@ public: NODISCARD FORCEINLINE constexpr decltype(auto) operator<=>(U InPtr) const& { return SynthThreeWayCompare(Ptr, InPtr); } /** @return The pointer to the object pointed to by the wrapped pointer. */ - NODISCARD FORCEINLINE constexpr ElementType* Get() { return TPointerTraits::ToAddress(Ptr); } - NODISCARD FORCEINLINE constexpr const ElementType* Get() const { return TPointerTraits::ToAddress(Ptr); } + NODISCARD FORCEINLINE constexpr FElementType* Get() { return TPointerTraits::ToAddress(Ptr); } + NODISCARD FORCEINLINE constexpr const FElementType* Get() const { return TPointerTraits::ToAddress(Ptr); } /** @return true if *this owns an object, false otherwise. */ NODISCARD FORCEINLINE constexpr bool IsValid() const { return Get() != nullptr; } NODISCARD FORCEINLINE constexpr explicit operator bool() const { return Get() != nullptr; } /** @return The a reference or pointer to the object owned by *this, i.e. Get(). */ - NODISCARD FORCEINLINE constexpr ElementType& operator*() { checkf(IsValid(), TEXT("Read access violation. Please check IsValid().")); return *Get(); } - NODISCARD FORCEINLINE constexpr const ElementType& operator*() const { checkf(IsValid(), TEXT("Read access violation. Please check IsValid().")); return *Get(); } - NODISCARD FORCEINLINE constexpr ElementType* operator->() { checkf(IsValid(), TEXT("Read access violation. Please check IsValid().")); return Get(); } - NODISCARD FORCEINLINE constexpr const ElementType* operator->() const { checkf(IsValid(), TEXT("Read access violation. Please check IsValid().")); return Get(); } + NODISCARD FORCEINLINE constexpr FElementType& operator*() { checkf(IsValid(), TEXT("Read access violation. Please check IsValid().")); return *Get(); } + NODISCARD FORCEINLINE constexpr const FElementType& operator*() const { checkf(IsValid(), TEXT("Read access violation. Please check IsValid().")); return *Get(); } + NODISCARD FORCEINLINE constexpr FElementType* operator->() { checkf(IsValid(), TEXT("Read access violation. Please check IsValid().")); return Get(); } + NODISCARD FORCEINLINE constexpr const FElementType* operator->() const { checkf(IsValid(), TEXT("Read access violation. Please check IsValid().")); return Get(); } /** @return The element at index, i.e. Get()[Index]. */ NODISCARD FORCEINLINE constexpr T& operator[](size_t Index) { checkf(IsValid(), TEXT("Read access violation. Please check IsValid().")); return Get()[Index]; } NODISCARD FORCEINLINE constexpr const T& operator[](size_t Index) const { checkf(IsValid(), TEXT("Read access violation. Please check IsValid().")); return Get()[Index]; } /** @return The pointer to the object pointed to by the wrapped pointer-like object. */ - NODISCARD FORCEINLINE constexpr operator ElementType*() requires (CConvertibleTo) { return Ptr; } - NODISCARD FORCEINLINE constexpr operator const ElementType*() const requires (CConvertibleTo) { return Ptr; } + NODISCARD FORCEINLINE constexpr operator FElementType*() requires (CConvertibleTo) { return Ptr; } + NODISCARD FORCEINLINE constexpr operator const FElementType*() const requires (CConvertibleTo) { return Ptr; } /** @return The reference to the pointer-like object stored. */ NODISCARD FORCEINLINE constexpr T& GetUnderlying() { return Ptr; } diff --git a/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h b/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h index 73a8f1c..945150b 100644 --- a/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h +++ b/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h @@ -22,7 +22,7 @@ class TReferenceWrapper final { public: - using Type = ReferencedType; + using FType = ReferencedType; /** Constructs a new reference wrapper. */ template requires (CConvertibleTo && !CSameAs>) @@ -111,10 +111,10 @@ NAMESPACE_PRIVATE_BEGIN template struct TIsTReferenceWrapperImpl : FFalse { }; template struct TIsTReferenceWrapperImpl> : FTrue { }; -template struct TUnwrapReferenceImpl { using Type = T; }; -template struct TUnwrapReferenceImpl> { using Type = T&; }; +template struct TUnwrapReferenceImpl { using FType = T; }; +template struct TUnwrapReferenceImpl> { using FType = T&; }; -template struct TUnwrapRefDecayImpl { using Type = typename TUnwrapReferenceImpl>::Type; }; +template struct TUnwrapRefDecayImpl { using FType = typename TUnwrapReferenceImpl>::FType; }; NAMESPACE_PRIVATE_END @@ -122,10 +122,10 @@ template concept CTReferenceWrapper = NAMESPACE_PRIVATE::TIsTReferenceWrapperImpl>::Value; template -using TUnwrapReference = typename NAMESPACE_PRIVATE::TUnwrapReferenceImpl::Type; +using TUnwrapReference = typename NAMESPACE_PRIVATE::TUnwrapReferenceImpl::FType; template -using TUnwrapRefDecay = typename NAMESPACE_PRIVATE::TUnwrapRefDecayImpl::Type; +using TUnwrapRefDecay = typename NAMESPACE_PRIVATE::TUnwrapRefDecayImpl::FType; NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) diff --git a/Redcraft.Utility/Source/Public/Templates/Tuple.h b/Redcraft.Utility/Source/Public/Templates/Tuple.h index 6696b97..2246203 100644 --- a/Redcraft.Utility/Source/Public/Templates/Tuple.h +++ b/Redcraft.Utility/Source/Public/Templates/Tuple.h @@ -49,7 +49,7 @@ struct TTupleElementImpl; template struct TTupleElementImpl> { - using Type = Meta::TType>; + using FType = Meta::TType>; }; template @@ -77,12 +77,12 @@ struct TTupleBasicElement { private: - using ValueType = T; - ValueType Value; + using FValueType = T; + FValueType Value; public: - template + template requires (CConstructibleFrom) FORCEINLINE constexpr TTupleBasicElement(Type&& Arg) : Value(Forward(Arg)) { } @@ -110,10 +110,10 @@ public: template \ struct TTupleBasicElement \ { \ - using Name##Type = T; \ - Name##Type Name; \ + using F##Name##Type = T; \ + F##Name##Type Name; \ \ - template \ + template requires (CConstructibleFrom) \ FORCEINLINE constexpr TTupleBasicElement(Type&& Arg) \ : Name(Forward(Arg)) \ { } \ @@ -315,15 +315,15 @@ template inline constexpr size_t TTupleIndex = NAMESPACE_PRIVATE::TTupleIndexImpl>::Value; template -using TTupleElement = TCopyCV>::Type>; +using TTupleElement = TCopyCV>::FType>; template class TTuple final : public NAMESPACE_PRIVATE::TTupleImpl, Ts...> { private: - using Super = NAMESPACE_PRIVATE::TTupleImpl, Ts...>; - using Helper = NAMESPACE_PRIVATE::TTupleHelper>; + using FSuper = NAMESPACE_PRIVATE::TTupleImpl, Ts...>; + using FHelper = NAMESPACE_PRIVATE::TTupleHelper>; public: @@ -334,7 +334,7 @@ public: template requires (sizeof...(Ts) >= 1 && sizeof...(Us) == sizeof...(Ts)) && (true && ... && CConstructibleFrom) FORCEINLINE constexpr explicit (!(true && ... && CConvertibleTo)) TTuple(Us&&... Args) - : Super(NAMESPACE_PRIVATE::ForwardingConstructor, Forward(Args)...) + : FSuper(NAMESPACE_PRIVATE::ForwardingConstructor, Forward(Args)...) { } /** Converting copy constructor. Initializes each element of the tuple with the corresponding element of other. */ @@ -342,7 +342,7 @@ public: && (true && ... && CConstructibleFrom) && NAMESPACE_PRIVATE::TTupleConvertCopy::Value) FORCEINLINE constexpr explicit (!(true && ... && CConvertibleTo)) TTuple(const TTuple& InValue) - : Super(NAMESPACE_PRIVATE::OtherTupleConstructor, InValue) + : FSuper(NAMESPACE_PRIVATE::OtherTupleConstructor, InValue) { } /** Converting move constructor. Initializes each element of the tuple with the corresponding element of other. */ @@ -350,7 +350,7 @@ public: && (true && ... && CConstructibleFrom) && NAMESPACE_PRIVATE::TTupleConvertMove::Value) FORCEINLINE constexpr explicit (!(true && ... && CConvertibleTo)) TTuple(TTuple&& InValue) - : Super(NAMESPACE_PRIVATE::OtherTupleConstructor, MoveTemp(InValue)) + : FSuper(NAMESPACE_PRIVATE::OtherTupleConstructor, MoveTemp(InValue)) { } /** Copies/moves content of other into a new instance. */ @@ -362,7 +362,7 @@ public: && (true && ... && CAssignableFrom)) FORCEINLINE constexpr TTuple& operator=(const TTuple& InValue) { - Helper::Assign(*this, InValue); + FHelper::Assign(*this, InValue); return *this; } @@ -371,7 +371,7 @@ public: && (true && ... && CAssignableFrom)) FORCEINLINE constexpr TTuple& operator=(TTuple&& InValue) { - Helper::Assign(*this, MoveTemp(InValue)); + FHelper::Assign(*this, MoveTemp(InValue)); return *this; } @@ -396,8 +396,8 @@ public: template requires (sizeof...(Ts) == sizeof...(Us) && NAMESPACE_PRIVATE::CTTupleSynthThreeWayComparable, TTypeSequence>) NODISCARD friend FORCEINLINE constexpr TCommonComparisonCategory...> operator<=>(const TTuple& LHS, const TTuple& RHS) { - using R = TCommonComparisonCategory...>; - return NAMESPACE_PRIVATE::TTupleThreeWay>::Do(LHS, RHS); + using FResult = TCommonComparisonCategory...>; + return NAMESPACE_PRIVATE::TTupleThreeWay>::Do(LHS, RHS); } /** Extracts the Ith element from the tuple. I must be an integer value in [0, sizeof...(Ts)). */ @@ -421,14 +421,14 @@ public: template NODISCARD FORCEINLINE constexpr decltype(auto) GetValue() const volatile&& { return static_cast(*this).GetValue>(); } /** Invoke the callable object 'Func' with a tuple of arguments. */ - 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 (CInvocable) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) & { return FHelper::Apply(Forward(Func), static_cast< TTuple& >(*this)); } + template requires (CInvocable) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) const & { return FHelper::Apply(Forward(Func), static_cast(*this)); } + template requires (CInvocable) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) volatile& { return FHelper::Apply(Forward(Func), static_cast< volatile TTuple& >(*this)); } + template requires (CInvocable) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) const volatile& { return FHelper::Apply(Forward(Func), static_cast(*this)); } + template requires (CInvocable) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) && { return FHelper::Apply(Forward(Func), static_cast< TTuple&&>(*this)); } + template requires (CInvocable) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) const && { return FHelper::Apply(Forward(Func), static_cast(*this)); } + template requires (CInvocable) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) volatile&& { return FHelper::Apply(Forward(Func), static_cast< volatile TTuple&&>(*this)); } + template requires (CInvocable) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) const volatile&& { return FHelper::Apply(Forward(Func), static_cast(*this)); } /** Visits each element in a tuple in parallel and applies it as arguments to the function. */ template requires (true && ... && CInvocable) FORCEINLINE constexpr void Visit(F&& Func) & { VisitTuple(Forward(Func), static_cast< TTuple& >(*this)); } @@ -461,24 +461,24 @@ public: template requires ((sizeof...(Ts) >= 1) && ... && CInvocableResult) FORCEINLINE constexpr Ret Visit(F&& Func, size_t Index) const volatile&& { return NAMESPACE_PRIVATE::TTupleVisitElementByIndex>::Do(Forward(Func), static_cast(*this), Index); } /** Transform a tuple into another tuple using the given function. */ - template requires (true && ... && (CInvocable && !CSameAs>)) NODISCARD FORCEINLINE constexpr decltype(auto) Transform(F&& Func) & { return Helper::Transform(Forward(Func), static_cast< TTuple& >(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) NODISCARD FORCEINLINE constexpr decltype(auto) Transform(F&& Func) const & { return Helper::Transform(Forward(Func), static_cast(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) NODISCARD FORCEINLINE constexpr decltype(auto) Transform(F&& Func) volatile& { return Helper::Transform(Forward(Func), static_cast< volatile TTuple& >(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) NODISCARD FORCEINLINE constexpr decltype(auto) Transform(F&& Func) const volatile& { return Helper::Transform(Forward(Func), static_cast(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) NODISCARD FORCEINLINE constexpr decltype(auto) Transform(F&& Func) && { return Helper::Transform(Forward(Func), static_cast< TTuple&&>(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) NODISCARD FORCEINLINE constexpr decltype(auto) Transform(F&& Func) const && { return Helper::Transform(Forward(Func), static_cast(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) NODISCARD FORCEINLINE constexpr decltype(auto) Transform(F&& Func) volatile&& { return Helper::Transform(Forward(Func), static_cast< volatile TTuple&&>(*this)); } - template requires (true && ... && (CInvocable && !CSameAs>)) NODISCARD FORCEINLINE constexpr decltype(auto) Transform(F&& Func) const volatile&& { return Helper::Transform(Forward(Func), static_cast(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) NODISCARD FORCEINLINE constexpr decltype(auto) Transform(F&& Func) & { return FHelper::Transform(Forward(Func), static_cast< TTuple& >(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) NODISCARD FORCEINLINE constexpr decltype(auto) Transform(F&& Func) const & { return FHelper::Transform(Forward(Func), static_cast(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) NODISCARD FORCEINLINE constexpr decltype(auto) Transform(F&& Func) volatile& { return FHelper::Transform(Forward(Func), static_cast< volatile TTuple& >(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) NODISCARD FORCEINLINE constexpr decltype(auto) Transform(F&& Func) const volatile& { return FHelper::Transform(Forward(Func), static_cast(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) NODISCARD FORCEINLINE constexpr decltype(auto) Transform(F&& Func) && { return FHelper::Transform(Forward(Func), static_cast< TTuple&&>(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) NODISCARD FORCEINLINE constexpr decltype(auto) Transform(F&& Func) const && { return FHelper::Transform(Forward(Func), static_cast(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) NODISCARD FORCEINLINE constexpr decltype(auto) Transform(F&& Func) volatile&& { return FHelper::Transform(Forward(Func), static_cast< volatile TTuple&&>(*this)); } + template requires (true && ... && (CInvocable && !CSameAs>)) NODISCARD FORCEINLINE constexpr decltype(auto) Transform(F&& Func) const volatile&& { return FHelper::Transform(Forward(Func), static_cast(*this)); } /** Constructs an object of type T with a tuple as an argument. */ - template requires (CConstructibleFrom) NODISCARD FORCEINLINE constexpr T Construct() & { return Helper::template Construct(static_cast< TTuple& >(*this)); } - template requires (CConstructibleFrom) NODISCARD FORCEINLINE constexpr T Construct() const & { return Helper::template Construct(static_cast(*this)); } - template requires (CConstructibleFrom) NODISCARD FORCEINLINE constexpr T Construct() volatile& { return Helper::template Construct(static_cast< volatile TTuple& >(*this)); } - template requires (CConstructibleFrom) NODISCARD FORCEINLINE constexpr T Construct() const volatile& { return Helper::template Construct(static_cast(*this)); } - template requires (CConstructibleFrom) NODISCARD FORCEINLINE constexpr T Construct() && { return Helper::template Construct(static_cast< TTuple&&>(*this)); } - template requires (CConstructibleFrom) NODISCARD FORCEINLINE constexpr T Construct() const && { return Helper::template Construct(static_cast(*this)); } - template requires (CConstructibleFrom) NODISCARD FORCEINLINE constexpr T Construct() volatile&& { return Helper::template Construct(static_cast< volatile TTuple&&>(*this)); } - template requires (CConstructibleFrom) NODISCARD FORCEINLINE constexpr T Construct() const volatile&& { return Helper::template Construct(static_cast(*this)); } + template requires (CConstructibleFrom) NODISCARD FORCEINLINE constexpr T Construct() & { return FHelper::template Construct(static_cast< TTuple& >(*this)); } + template requires (CConstructibleFrom) NODISCARD FORCEINLINE constexpr T Construct() const & { return FHelper::template Construct(static_cast(*this)); } + template requires (CConstructibleFrom) NODISCARD FORCEINLINE constexpr T Construct() volatile& { return FHelper::template Construct(static_cast< volatile TTuple& >(*this)); } + template requires (CConstructibleFrom) NODISCARD FORCEINLINE constexpr T Construct() const volatile& { return FHelper::template Construct(static_cast(*this)); } + template requires (CConstructibleFrom) NODISCARD FORCEINLINE constexpr T Construct() && { return FHelper::template Construct(static_cast< TTuple&&>(*this)); } + template requires (CConstructibleFrom) NODISCARD FORCEINLINE constexpr T Construct() const && { return FHelper::template Construct(static_cast(*this)); } + template requires (CConstructibleFrom) NODISCARD FORCEINLINE constexpr T Construct() volatile&& { return FHelper::template Construct(static_cast< volatile TTuple&&>(*this)); } + template requires (CConstructibleFrom) NODISCARD FORCEINLINE constexpr T Construct() const volatile&& { return FHelper::template Construct(static_cast(*this)); } /** @return The number of elements in the tuple. */ NODISCARD static FORCEINLINE constexpr size_t Num() { return sizeof...(Ts); } @@ -555,13 +555,13 @@ struct TTupleCatResultImpl; template struct TTupleCatResultImpl, TTupleTypes...> { - using Type = typename TTupleCatResultImpl::Type; + using FType = typename TTupleCatResultImpl::FType; }; template struct TTupleCatResultImpl { - using Type = TTuple; + using FType = TTuple; }; template @@ -571,14 +571,14 @@ template struct TTupleCatMake, TIndexSequence> { template - struct ForwardType { using Type = TConditional, TRemoveReference&&, U>; }; + struct FForwardType { using FType = TConditional, TRemoveReference&&, U>; }; template FORCEINLINE static constexpr TTuple Do(TTupleType&& InValue) { return TTuple ( - static_cast(InValue).template GetValue())>::Type> + static_cast(InValue).template GetValue())>::FType> ( Forward(InValue).template GetValue() )... @@ -642,15 +642,15 @@ struct TTupleVisitImpl> NAMESPACE_PRIVATE_END template requires (true && ... && CTTuple>) -using TTupleCatResult = typename NAMESPACE_PRIVATE::TTupleCatResultImpl..., NAMESPACE_PRIVATE::FTupleEndFlag>::Type;; +using TTupleCatResult = typename NAMESPACE_PRIVATE::TTupleCatResultImpl..., NAMESPACE_PRIVATE::FTupleEndFlag>::FType; /** Creates a tuple by concatenating any number of tuples. */ template requires (true && ... && CTTuple>) FORCEINLINE constexpr decltype(auto) TupleCat(TTupleTypes&&... Args) { - using R = TTupleCatResult; - if constexpr (sizeof...(Args) == 0) return R(); - else return NAMESPACE_PRIVATE::TTupleCatImpl::Do(Forward(Args)...); + using FResult = TTupleCatResult; + if constexpr (sizeof...(Args) == 0) return FResult(); + else return NAMESPACE_PRIVATE::TTupleCatImpl::Do(Forward(Args)...); } /** @@ -679,20 +679,22 @@ FORCEINLINE constexpr void VisitTuple(F&& Func, FirstTupleType&& FirstTuple, Tup template requires (requires { typename TTuple...>; }) struct TBasicCommonType, TTuple> { - using Type = TTuple...>; + using FType = TTuple...>; }; template typename TQualifiers, template typename UQualifiers> requires (requires { typename TTuple, UQualifiers>...>; }) struct TBasicCommonReference, TTuple, TQualifiers, UQualifiers> { - using Type = TTuple, UQualifiers>...>; + using FType = TTuple, UQualifiers>...>; }; NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END +// ReSharper disable CppInconsistentNaming + NAMESPACE_STD_BEGIN // Support structure binding, should not be directly used. @@ -718,3 +720,5 @@ template FORCEINLINE constexpr decltype(auto) get NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END + +// ReSharper restore CppInconsistentNaming diff --git a/Redcraft.Utility/Source/Public/Templates/Utility.h b/Redcraft.Utility/Source/Public/Templates/Utility.h index 29ff1b0..dd78dec 100644 --- a/Redcraft.Utility/Source/Public/Templates/Utility.h +++ b/Redcraft.Utility/Source/Public/Templates/Utility.h @@ -24,8 +24,8 @@ void AsConst(const T&& Ref) = delete; template FORCEINLINE constexpr TRemoveReference&& MoveTemp(T&& Obj) { - using CastType = TRemoveReference; - return static_cast(Obj); + using FCastType = TRemoveReference; + return static_cast(Obj); } /** CopyTemp will enforce the creation of an rvalue which can bind to rvalue reference parameters. */ diff --git a/Redcraft.Utility/Source/Public/Templates/Variant.h b/Redcraft.Utility/Source/Public/Templates/Variant.h index 092fc3e..108c6dd 100644 --- a/Redcraft.Utility/Source/Public/Templates/Variant.h +++ b/Redcraft.Utility/Source/Public/Templates/Variant.h @@ -40,30 +40,30 @@ struct TVariantAlternativeImpl; template struct TVariantAlternativeImpl> { - using Type = Meta::TType>; + using FType = Meta::TType>; }; template struct TVariantOverloadType { - using FrontType = Meta::TFront; - using NextSequence = Meta::TPop; - using NextUniqueSequence = typename TVariantOverloadType::Type; + using FFrontType = Meta::TFront; + using FNextSequence = Meta::TPop; + using FNextUniqueSequence = typename TVariantOverloadType::FType; // T_i x[] = { Forward(t) }; - static constexpr bool bConditional = requires { DeclVal()({ DeclVal() }); }; + static constexpr bool bConditional = requires { DeclVal()({ DeclVal() }); }; - using Type = TConditional, NextUniqueSequence>; + using FType = TConditional, FNextUniqueSequence>; }; template struct TVariantOverloadType> { - using Type = TTypeSequence<>; + using FType = TTypeSequence<>; }; template -using TVariantSelectedType = Meta::TOverloadResolution>::Type>; +using TVariantSelectedType = Meta::TOverloadResolution>::FType>; NAMESPACE_PRIVATE_END @@ -77,7 +77,7 @@ template inline constexpr size_t TVariantIndex = NAMESPACE_PRIVATE::TVariantIndexImpl>::Value; template -using TVariantAlternative = TCopyCV>::Type>; +using TVariantAlternative = TCopyCV>::FType>; /** * The class template TVariant represents a type-safe union. An instance of TVariant @@ -113,7 +113,7 @@ public: { if (IsValid()) MoveConstructImpl[InValue.GetIndex()](&Value, &InValue.Value); } - + /** * Converting constructor. Constructs a variant holding the alternative type that would be selected * by overload resolution for the expression F(Forward(InValue)) if there was an overload of @@ -126,7 +126,7 @@ public: && !CSameAs>) FORCEINLINE constexpr TVariant(T&& InValue) : TVariant(InPlaceType>, Forward(InValue)) { } - + /** Constructs a variant with the specified alternative T and initializes the contained value with the arguments Forward(Args).... */ template requires (CConstructibleFrom) FORCEINLINE constexpr explicit TVariant(TInPlaceType, Us&&... Args) @@ -139,10 +139,10 @@ public: FORCEINLINE constexpr explicit TVariant(TInPlaceIndex, Us&&... Args) : TypeIndex(I) { - using SelectedType = TVariantAlternative>; - new (&Value) SelectedType(Forward(Args)...); + using FSelectedType = TVariantAlternative>; + new (&Value) FSelectedType(Forward(Args)...); } - + /** Constructs a variant with the specified alternative T and initializes the contained value with the arguments IL, Forward(Args).... */ template requires (CConstructibleFrom, Us...>) FORCEINLINE constexpr explicit TVariant(TInPlaceType, initializer_list IL, Us&&... Args) @@ -155,8 +155,8 @@ public: FORCEINLINE constexpr explicit TVariant(TInPlaceIndex, initializer_list IL, Us&&... Args) : TypeIndex(I) { - using SelectedType = TVariantAlternative>; - new (&Value) SelectedType(IL, Forward(Args)...); + using FSelectedType = TVariantAlternative>; + new (&Value) FSelectedType(IL, Forward(Args)...); } /** Destroys the contained object, if any, as if by a call to Reset(). */ @@ -185,7 +185,7 @@ public: if (GetIndex() == InValue.GetIndex()) CopyAssignImpl[InValue.GetIndex()](&Value, &InValue.Value); else - { + { Reset(); CopyConstructImpl[InValue.GetIndex()](&Value, &InValue.Value); TypeIndex = static_cast(InValue.GetIndex()); @@ -224,14 +224,14 @@ public: template requires (requires { typename NAMESPACE_PRIVATE::TVariantSelectedType; }) FORCEINLINE constexpr TVariant& operator=(T&& InValue) { - using SelectedType = NAMESPACE_PRIVATE::TVariantSelectedType; + using FSelectedType = NAMESPACE_PRIVATE::TVariantSelectedType; - if (GetIndex() == TVariantIndex>) GetValue() = Forward(InValue); + if (GetIndex() == TVariantIndex>) GetValue() = Forward(InValue); else { Reset(); - new (&Value) SelectedType(Forward(InValue)); - TypeIndex = TVariantIndex>; + new (&Value) FSelectedType(Forward(InValue)); + TypeIndex = TVariantIndex>; } return *this; @@ -277,7 +277,7 @@ public: /** @return true if instance does not contain a value, otherwise false. */ NODISCARD FORCEINLINE constexpr bool operator==(FInvalid) const& { return !IsValid(); } - + /** Equivalent to Emplace(Forward(Args)...), where I is the zero-based index of T in Types.... */ template requires (CConstructibleFrom) FORCEINLINE constexpr T& Emplace(Us&&... Args) @@ -290,7 +290,7 @@ public: * Then direct-initializes the contained value as if constructing a value of type T with the arguments Forward(Args).... * * @param Args - The arguments to be passed to the constructor of the contained object. - * + * * @return A reference to the new contained object. */ template requires (I < sizeof...(Ts) @@ -299,13 +299,13 @@ public: { Reset(); - using SelectedType = TVariantAlternative>; - SelectedType* Result = new (&Value) SelectedType(Forward(Args)...); + using FSelectedType = TVariantAlternative>; + FSelectedType* Result = new (&Value) FSelectedType(Forward(Args)...); TypeIndex = I; return *Result; } - + /** Equivalent to Emplace(IL, Forward(Args)...), where I is the zero-based index of T in Types.... */ template requires (CConstructibleFrom, Us...>) FORCEINLINE constexpr T& Emplace(initializer_list IL, Us&&... Args) @@ -318,7 +318,7 @@ public: * Then direct-initializes the contained value as if constructing a value of type T with the arguments IL, Forward(Args).... * * @param IL, Args - The arguments to be passed to the constructor of the contained object. - * + * * @return A reference to the new contained object. */ template requires (I < sizeof...(Ts) @@ -327,8 +327,8 @@ public: { Reset(); - using SelectedType = TVariantAlternative>; - SelectedType* Result = new (&Value) SelectedType(IL, Forward(Args)...); + using FSelectedType = TVariantAlternative>; + FSelectedType* Result = new (&Value) FSelectedType(IL, Forward(Args)...); TypeIndex = I; return *Result; @@ -423,7 +423,7 @@ public: } private: - + static constexpr const type_info* TypeInfos[] = { &typeid(Ts)... }; using FCopyConstructImpl = void(*)(void*, const void*); @@ -448,7 +448,7 @@ NAMESPACE_PRIVATE_BEGIN template struct TVariantVisitImpl { - struct GetTotalNum + struct FGetTotalNum { FORCEINLINE static constexpr size_t Do() { @@ -464,10 +464,10 @@ struct TVariantVisitImpl } return Result; - }; + } }; - struct EncodeIndices + struct FEncodeIndices { FORCEINLINE static constexpr size_t Do(initializer_list Indices) { @@ -482,10 +482,10 @@ struct TVariantVisitImpl } return Result; - }; + } }; - struct DecodeExtent + struct FDecodeExtent { FORCEINLINE static constexpr size_t Do(size_t EncodedIndex, size_t Extent) { @@ -497,76 +497,76 @@ struct TVariantVisitImpl } return EncodedIndex % VariantNums[Extent]; - }; + } }; template - struct InvokeEncoded; + struct FInvokeEncoded; template - struct InvokeEncoded> + struct FInvokeEncoded> { FORCEINLINE static constexpr decltype(auto) Do(F&& Func, VariantTypes&&... Variants) { - return Invoke(Forward(Func), Forward(Variants).template GetValue()...); + return Invoke(Forward(Func), Forward(Variants).template GetValue()...); } template - struct Result + struct FResult { FORCEINLINE static constexpr Ret Do(F&& Func, VariantTypes&&... Variants) { - return InvokeResult(Forward(Func), Forward(Variants).template GetValue()...); + return InvokeResult(Forward(Func), Forward(Variants).template GetValue()...); } }; }; template - struct InvokeVariant; + struct FInvokeVariant; template - struct InvokeVariant> + struct FInvokeVariant> { FORCEINLINE static constexpr decltype(auto) Do(F&& Func, VariantTypes&&... Variants) { - using ExtentIndices = TIndexSequenceFor; + using FExtentIndices = TIndexSequenceFor; - using ResultType = TCommonType::Do(Forward(Func), Forward(Variants)...))...>; - - using InvokeImplType = ResultType(*)(F&&, VariantTypes&&...); + using FResultType = TCommonType::Do(Forward(Func), Forward(Variants)...))...>; - constexpr InvokeImplType InvokeImpl[] = { InvokeEncoded::template Result::Do... }; + using FInvokeImplType = FResultType(*)(F&&, VariantTypes&&...); - return InvokeImpl[EncodeIndices::Do({ Variants.GetIndex()... })](Forward(Func), Forward(Variants)...); + constexpr FInvokeImplType InvokeImpl[] = { FInvokeEncoded::template FResult::Do... }; + + return InvokeImpl[FEncodeIndices::Do({ Variants.GetIndex()... })](Forward(Func), Forward(Variants)...); } template - struct Result + struct FResult { FORCEINLINE static constexpr Ret Do(F&& Func, VariantTypes&&... Variants) { - using ExtentIndices = TIndexSequenceFor; + using FExtentIndices = TIndexSequenceFor; - using InvokeImplType = Ret(*)(F&&, VariantTypes&&...); + using FInvokeImplType = Ret(*)(F&&, VariantTypes&&...); - constexpr InvokeImplType InvokeImpl[] = { InvokeEncoded::template Result::Do... }; + constexpr FInvokeImplType InvokeImpl[] = { FInvokeEncoded::template FResult::Do... }; - return InvokeImpl[EncodeIndices::Do({ Variants.GetIndex()... })](Forward(Func), Forward(Variants)...); + return InvokeImpl[FEncodeIndices::Do({ Variants.GetIndex()... })](Forward(Func), Forward(Variants)...); } }; }; FORCEINLINE static constexpr decltype(auto) Do(F&& Func, VariantTypes&&... Variants) { - return InvokeVariant>::Do(Forward(Func), Forward(Variants)...); + return FInvokeVariant>::Do(Forward(Func), Forward(Variants)...); } template - struct Result + struct FResult { FORCEINLINE static constexpr Ret Do(F&& Func, VariantTypes&&... Variants) { - return InvokeVariant>::template Result::Do(Forward(Func), Forward(Variants)...); + return FInvokeVariant>::template FResult::Do(Forward(Func), Forward(Variants)...); } }; }; @@ -588,7 +588,7 @@ template ::template Result::Do(Forward(Func), Forward(FirstVariant), Forward(Variants)...); + return NAMESPACE_PRIVATE::TVariantVisitImpl::template FResult::Do(Forward(Func), Forward(FirstVariant), Forward(Variants)...); } NAMESPACE_MODULE_END(Utility) diff --git a/Redcraft.Utility/Source/Public/TypeTraits/Common.h b/Redcraft.Utility/Source/Public/TypeTraits/Common.h index 581dbfb..dfe0a57 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/Common.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/Common.h @@ -20,58 +20,58 @@ template typename TQualifiers, temp NAMESPACE_PRIVATE_BEGIN -// Template class declaration for the common Type implementation +// Template class declaration for the common type implementation template struct TCommonTypeImpl; -// If sizeof...(Ts) is zero, there is no member Type +// If sizeof...(Ts) is zero, there is no member FType template <> struct TCommonTypeImpl<> { }; -// If sizeof...(Ts) is one, the member Type names the same Type as TCommonType if it exists; otherwise there is no member Type +// If sizeof...(Ts) is one, the member FType names the same type as TCommonType if it exists; otherwise there is no member FType template struct TCommonTypeImpl : TCommonTypeImpl { }; // If sizeof...(Ts) is two -// If applying TDecay to at least one of T and U produces a different Type, the member Type names the same Type as TCommonType, TDecay>, if it exists; if not, there is no member Type +// If applying TDecay to at least one of T and U produces a different type, the member FType names the same type as TCommonType, TDecay>, if it exists; if not, there is no member FType template concept CDecayed = CSameAs> && CSameAs>; template requires (!CDecayed) struct TCommonTypeImpl : TCommonTypeImpl, TDecay> { }; -// Otherwise, if there is a user specialization for TBasicCommonType::Type, that specialization is used -template concept CBasicCommonType = requires { typename TBasicCommonType::Type; }; +// Otherwise, if there is a user specialization for TBasicCommonType::FType, that specialization is used +template concept CBasicCommonType = requires { typename TBasicCommonType::FType; }; template requires (CDecayed && CBasicCommonType) struct TCommonTypeImpl : TBasicCommonType { // If such a specialization has a member named type, // it must be a public and unambiguous member that names a cv-unqualified non-reference type to which both T and U are explicitly convertible - // Additionally, TBasicCommonType::Type and TBasicCommonType::Type must denote the same type - static_assert(CSameAs::Type, TDecay::Type>>, "The basic common type must be a cv-unqualified non-reference type"); - static_assert(CConstructibleFrom::Type, T&&> && CConstructibleFrom::Type, U&&>, "The basic common type must be a type which both T and U are explicitly convertible"); - static_assert(CSameAs::Type, typename TBasicCommonType::Type>, "TBasicCommonType::Type and TBasicCommonType::Type must denote the same type"); + // Additionally, TBasicCommonType::FType and TBasicCommonType::FType must denote the same type + static_assert(CSameAs::FType, TDecay::FType>>, "The basic common type must be a cv-unqualified non-reference type"); + static_assert(CConstructibleFrom::FType, T&&> && CConstructibleFrom::FType, U&&>, "The basic common type must be a type which both T and U are explicitly convertible"); + static_assert(CSameAs::FType, typename TBasicCommonType::FType>, "TBasicCommonType::FType and TBasicCommonType::FType must denote the same type"); }; -// Otherwise, if TDecay() : DeclVal())> is a valid Type, the member Type denotes that Type +// Otherwise, if TDecay() : DeclVal())> is a valid type, the member FType denotes that type template concept CConditionalType = requires { typename TDecay() : DeclVal())>; }; template requires (CDecayed && !CBasicCommonType && CConditionalType) -struct TCommonTypeImpl { using Type = TDecay() : DeclVal())>; }; +struct TCommonTypeImpl { using FType = TDecay() : DeclVal())>; }; -// Otherwise, if TDecay() : DeclVal())> is a valid Type, -// where CRT and CRU are const TRemoveReference& and const TRemoveReference& respectively, the member Type denotes that Type +// Otherwise, if TDecay() : DeclVal())> is a valid type, +// where CRT and CRU are const TRemoveReference& and const TRemoveReference& respectively, the member FType denotes that type template concept CConditionalCRefType = requires { typename TDecay&>() : DeclVal&>())>; }; template requires (CDecayed && !CBasicCommonType && !CConditionalType && CConditionalCRefType) -struct TCommonTypeImpl { using Type = TDecay&>() : DeclVal&>())>; }; +struct TCommonTypeImpl { using FType = TDecay&>() : DeclVal&>())>; }; -// Otherwise, there is no member Type +// Otherwise, there is no member FType // If sizeof...(Ts) is greater than two -// If TCommonType exists, the member Type denotes TCommonType, R...> if such a Type exists -template requires (requires { typename TCommonTypeImpl::Type; }) -struct TCommonTypeImpl : TCommonTypeImpl::Type, W, Ts...> { }; +// If TCommonType exists, the member FType denotes TCommonType, R...> if such a type exists +template requires (requires { typename TCommonTypeImpl::FType; }) +struct TCommonTypeImpl : TCommonTypeImpl::FType, W, Ts...> { }; -// In all other cases, there is no member Type +// In all other cases, there is no member FType template struct TCommonTypeImpl { }; @@ -83,7 +83,7 @@ NAMESPACE_PRIVATE_BEGIN template struct TCommonReferenceImpl; -// Template class declaration for the simple common reference Type implementation +// Template class declaration for the simple common reference type implementation template struct TSimpleCommonReferenceImpl; @@ -91,89 +91,89 @@ struct TSimpleCommonReferenceImpl; template struct TQualifiersImpl; -// If sizeof...(T) is zero, there is no member Type +// If sizeof...(T) is zero, there is no member FType template <> struct TCommonReferenceImpl<> { }; -// If sizeof...(T) is one, the member Type names the same Type as T +// If sizeof...(T) is one, the member FType names the same type as T template -struct TCommonReferenceImpl { using Type = T; }; +struct TCommonReferenceImpl { using FType = T; }; // If sizeof...(Ts) is two -// If T and U are both reference types, and the simple common reference Type S of T and U exists, then the member Type Type names S -template concept CSimpleCommonReference = requires { typename TSimpleCommonReferenceImpl::Type; }; +// If T and U are both reference types, and the simple common reference type S of T and U exists, then the member FType names S +template concept CSimpleCommonReference = requires { typename TSimpleCommonReferenceImpl::FType; }; template requires (CSimpleCommonReference) struct TCommonReferenceImpl : TSimpleCommonReferenceImpl { }; -// Otherwise, if TBasicCommonReference, TRemoveCVRef, TQ, UQ>::Type exists -template struct TBasicCommonReferenceImpl : TBasicCommonReference, TRemoveCVRef, TQualifiersImpl::template Apply, TQualifiersImpl::template Apply> { }; -template concept CBasicCommonReference = requires { typename TBasicCommonReferenceImpl::Type; }; +// Otherwise, if TBasicCommonReference, TRemoveCVRef, TQ, UQ>::FType exists +template struct TBasicCommonReferenceImpl : TBasicCommonReference, TRemoveCVRef, TQualifiersImpl::template FApply, TQualifiersImpl::template FApply> { }; +template concept CBasicCommonReference = requires { typename TBasicCommonReferenceImpl::FType; }; template requires (!CSimpleCommonReference && CBasicCommonReference) struct TCommonReferenceImpl : TBasicCommonReferenceImpl { // If such a specialization has a member named type, // it must be a public and unambiguous member that names a type to which both TQualifiers and UQualifiers are convertible - // Additionally, TBasicCommonReference::Type and TBasicCommonReference::Type must denote the same type - static_assert(CConvertibleTo::Type> && CConvertibleTo::Type>, "The basic common reference must be a type to which both TQualifiers and UQualifiers are convertible"); - static_assert(CSameAs::Type, typename TBasicCommonReferenceImpl::Type>, "TBasicCommonReference::Type and TBasicCommonReference::Type must denote the same type"); + // Additionally, TBasicCommonReference::FType and TBasicCommonReference::FType must denote the same type + static_assert(CConvertibleTo::FType> && CConvertibleTo::FType>, "The basic common reference must be a type to which both TQualifiers and UQualifiers are convertible"); + static_assert(CSameAs::FType, typename TBasicCommonReferenceImpl::FType>, "TBasicCommonReference::FType and TBasicCommonReference::FType must denote the same type"); }; -// Where TQ and UQ is a unary alias template such that TQ is U with the addition of T's cv-ref qualifiers, then the member Type Type names that Type -template struct TQualifiersImpl { template using Apply = TCopyCV; }; -template struct TQualifiersImpl { template using Apply = TAddLValueReference>; }; -template struct TQualifiersImpl { template using Apply = TAddRValueReference>; }; +// Where TQ and UQ is a unary alias template such that TQ is U with the addition of T's cv-ref qualifiers, then the member FType names that type +template struct TQualifiersImpl { template using FApply = TCopyCV; }; +template struct TQualifiersImpl { template using FApply = TAddLValueReference>; }; +template struct TQualifiersImpl { template using FApply = TAddRValueReference>; }; -// Otherwise, if decltype(false ? Val() : Val()), where val is a function template template T Val();, is a valid Type, then the member Type Type names that Type +// Otherwise, if decltype(false ? Val() : Val()), where val is a function template T Val();, is a valid type, then the member FType names that type template T Val(); template concept CConditionalValType = requires { typename TVoid() : Val())>; }; template requires (!CSimpleCommonReference && !CBasicCommonReference && CConditionalValType) -struct TCommonReferenceImpl { using Type = decltype(false ? Val() : Val()); }; +struct TCommonReferenceImpl { using FType = decltype(false ? Val() : Val()); }; -// Otherwise, if TCommonType is a valid Type, then the member Type Type names that Type +// Otherwise, if TCommonType is a valid type, then the member FType names that type template concept CCommonTypeImpl = requires { typename TCommonTypeImpl; }; template requires (!CSimpleCommonReference && !CBasicCommonReference && !CConditionalValType && CCommonTypeImpl) struct TCommonReferenceImpl : TCommonTypeImpl { }; -// Otherwise, there is no member Type +// Otherwise, there is no member FType // If sizeof...(Ts) is greater than two -// If TCommonReference exists, the member Type denotes TCommonReference, R...> if such a Type exists -template requires (requires { typename TCommonReferenceImpl::Type; }) -struct TCommonReferenceImpl : TCommonReferenceImpl::Type, W, Ts...> { }; +// If TCommonReference exists, the member FType denotes TCommonReference, R...> if such a type exists +template requires (requires { typename TCommonReferenceImpl::FType; }) +struct TCommonReferenceImpl : TCommonReferenceImpl::FType, W, Ts...> { }; -// In all other cases, there is no member Type +// In all other cases, there is no member FType template struct TCommonReferenceImpl { }; // If T is CV1 X & and U is CV2 Y & (i.e., both are lvalue reference types): -// their simple common reference Type is decltype(false ? DeclVal() : DeclVal()), -// where CV12 is the union of CV1 and CV2, if that Type exists and is a reference Type +// their simple common reference type is decltype(false ? DeclVal() : DeclVal()), +// where CV12 is the union of CV1 and CV2, if that type exists and is a reference type template requires (CLValueReference&>() : DeclVal&>())>) -struct TSimpleCommonReferenceImpl { using Type = decltype(false ? DeclVal&>() : DeclVal&>()); }; +struct TSimpleCommonReferenceImpl { using FType = decltype(false ? DeclVal&>() : DeclVal&>()); }; // If T and U are both rvalue reference types: -// if the simple common reference Type of T & and U & exists, then let C denote that Type's corresponding rvalue reference Type -// If CConvertibleTo and CConvertibleTo are both true, then the simple common reference Type of T and U is C -template requires (CConvertibleTo::Type> &&> && CConvertibleTo::Type> &&>) -struct TSimpleCommonReferenceImpl { using Type = TRemoveReference::Type> &&; }; +// if the simple common reference type of T & and U & exists, then let C denote that type's corresponding rvalue reference type +// If CConvertibleTo and CConvertibleTo are both true, then the simple common reference type of T and U is C +template requires (CConvertibleTo::FType> &&> && CConvertibleTo::FType> &&>) +struct TSimpleCommonReferenceImpl { using FType = TRemoveReference::FType> &&; }; -// Otherwise, one of the two types must be an lvalue reference Type A & and the other must be an rvalue reference Type B && -// Let D denote the simple common reference Type of A & and B const &, if any -// If D exists and CConvertibleTo is true, then the simple common reference Type is D -template requires (CConvertibleTo::Type>) -struct TSimpleCommonReferenceImpl { using Type = typename TSimpleCommonReferenceImpl::Type; }; +// Otherwise, one of the two types must be a lvalue reference type A & and the other must be a rvalue reference type B && +// Let D denote the simple common reference type of A & and B const &, if any +// If D exists and CConvertibleTo is true, then the simple common reference type is D +template requires (CConvertibleTo::FType>) +struct TSimpleCommonReferenceImpl { using FType = typename TSimpleCommonReferenceImpl::FType; }; template struct TSimpleCommonReferenceImpl : TSimpleCommonReferenceImpl { }; // The order is not important -// Otherwise, there's no simple common reference Type +// Otherwise, there's no simple common reference type template struct TSimpleCommonReferenceImpl { }; NAMESPACE_PRIVATE_END -template using TCommonType = typename NAMESPACE_PRIVATE::TCommonTypeImpl::Type; -template using TCommonReference = typename NAMESPACE_PRIVATE::TCommonReferenceImpl::Type; +template using TCommonType = typename NAMESPACE_PRIVATE::TCommonTypeImpl::FType; +template using TCommonReference = typename NAMESPACE_PRIVATE::TCommonReferenceImpl::FType; template concept CCommonReference = diff --git a/Redcraft.Utility/Source/Public/TypeTraits/CopyQualifiers.h b/Redcraft.Utility/Source/Public/TypeTraits/CopyQualifiers.h index de59fbd..5ac6348 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/CopyQualifiers.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/CopyQualifiers.h @@ -11,35 +11,35 @@ NAMESPACE_MODULE_BEGIN(Utility) NAMESPACE_PRIVATE_BEGIN -template struct TCopyConstImpl { using Type = To; }; -template struct TCopyConstImpl { using Type = const To; }; +template struct TCopyConstImpl { using FType = To; }; +template struct TCopyConstImpl { using FType = const To; }; -template struct TCopyVolatileImpl { using Type = To; }; -template struct TCopyVolatileImpl { using Type = volatile To; }; +template struct TCopyVolatileImpl { using FType = To; }; +template struct TCopyVolatileImpl { using FType = volatile To; }; -template struct TCopyCVImpl { using Type = typename TCopyConstImpl::Type>::Type; }; +template struct TCopyCVImpl { using FType = typename TCopyConstImpl::FType>::FType; }; -template struct TCopyReferenceImpl { using Type = To; }; -template struct TCopyReferenceImpl { using Type = To&; }; -template struct TCopyReferenceImpl { using Type = To&&; }; +template struct TCopyReferenceImpl { using FType = To; }; +template struct TCopyReferenceImpl { using FType = To&; }; +template struct TCopyReferenceImpl { using FType = To&&; }; -template struct TCopyCVRefImpl { using Type = typename TCopyCVImpl::Type; }; -template struct TCopyCVRefImpl { using Type = typename TCopyCVImpl::Type&; }; -template struct TCopyCVRefImpl { using Type = typename TCopyCVImpl::Type&&; }; -template struct TCopyCVRefImpl { using Type = typename TCopyCVImpl::Type&; }; -template struct TCopyCVRefImpl { using Type = typename TCopyCVImpl::Type&; }; -template struct TCopyCVRefImpl { using Type = typename TCopyCVImpl::Type&; }; -template struct TCopyCVRefImpl { using Type = typename TCopyCVImpl::Type&&; }; -template struct TCopyCVRefImpl { using Type = typename TCopyCVImpl::Type&; }; -template struct TCopyCVRefImpl { using Type = typename TCopyCVImpl::Type&&; }; +template struct TCopyCVRefImpl { using FType = typename TCopyCVImpl::FType; }; +template struct TCopyCVRefImpl { using FType = typename TCopyCVImpl::FType&; }; +template struct TCopyCVRefImpl { using FType = typename TCopyCVImpl::FType&&; }; +template struct TCopyCVRefImpl { using FType = typename TCopyCVImpl::FType&; }; +template struct TCopyCVRefImpl { using FType = typename TCopyCVImpl::FType&; }; +template struct TCopyCVRefImpl { using FType = typename TCopyCVImpl::FType&; }; +template struct TCopyCVRefImpl { using FType = typename TCopyCVImpl::FType&&; }; +template struct TCopyCVRefImpl { using FType = typename TCopyCVImpl::FType&; }; +template struct TCopyCVRefImpl { using FType = typename TCopyCVImpl::FType&&; }; NAMESPACE_PRIVATE_END -template using TCopyConst = typename NAMESPACE_PRIVATE::TCopyConstImpl::Type; -template using TCopyVolatile = typename NAMESPACE_PRIVATE::TCopyVolatileImpl::Type; -template using TCopyCV = typename NAMESPACE_PRIVATE::TCopyCVImpl::Type; -template using TCopyReference = typename NAMESPACE_PRIVATE::TCopyReferenceImpl::Type; -template using TCopyCVRef = typename NAMESPACE_PRIVATE::TCopyCVRefImpl::Type; +template using TCopyConst = typename NAMESPACE_PRIVATE::TCopyConstImpl ::FType; +template using TCopyVolatile = typename NAMESPACE_PRIVATE::TCopyVolatileImpl ::FType; +template using TCopyCV = typename NAMESPACE_PRIVATE::TCopyCVImpl ::FType; +template using TCopyReference = typename NAMESPACE_PRIVATE::TCopyReferenceImpl::FType; +template using TCopyCVRef = typename NAMESPACE_PRIVATE::TCopyCVRefImpl ::FType; NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) diff --git a/Redcraft.Utility/Source/Public/TypeTraits/HelperClasses.h b/Redcraft.Utility/Source/Public/TypeTraits/HelperClasses.h index 6a1a719..ca0f87b 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/HelperClasses.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/HelperClasses.h @@ -6,14 +6,14 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -template +template struct TConstant { - using ValueType = InType; - using Type = TConstant; - static constexpr ValueType Value = InValue; - FORCEINLINE constexpr operator ValueType() const { return Value; } - FORCEINLINE constexpr ValueType operator()() const { return Value; } + using FValueType = T; + using FType = TConstant; + static constexpr FValueType Value = InValue; + FORCEINLINE constexpr operator FValueType() const { return Value; } + FORCEINLINE constexpr FValueType operator()() const { return Value; } }; template