diff --git a/Redcraft.Utility/Source/Private/Testing/MemoryTesting.cpp b/Redcraft.Utility/Source/Private/Testing/MemoryTesting.cpp index 023ad5b..8d46f58 100644 --- a/Redcraft.Utility/Source/Private/Testing/MemoryTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/MemoryTesting.cpp @@ -2,6 +2,9 @@ #include "Memory/Memory.h" #include "Memory/Alignment.h" +#include "Memory/PointerTraits.h" +#include "Memory/UniquePointer.h" +#include "Memory/SharedPointer.h" #include "Memory/MemoryOperator.h" #include "Miscellaneous/AssertionMacros.h" @@ -17,6 +20,9 @@ void TestMemory() TestMemoryBuffer(); TestMemoryMalloc(); TestMemoryOperator(); + TestPointerTraits(); + TestUniquePointer(); + TestSharedPointer(); } void TestAlignment() @@ -206,6 +212,825 @@ void TestMemoryOperator() Memory::Free(PtrB); } +void TestPointerTraits() +{ + always_check(!TPointerTraits::bIsPointer); + + always_check(TPointerTraits::bIsPointer); + always_check((CSameAs::PointerType, int64*>)); + always_check((CSameAs::ElementType, int64>)); + always_check(TPointerTraits::ToAddress(nullptr) == nullptr); + + always_check(TPointerTraits::bIsPointer); + always_check((CSameAs::PointerType, int64(*)[]>)); + always_check((CSameAs::ElementType, int64>)); + always_check(TPointerTraits::ToAddress(nullptr) == nullptr); + + always_check(TPointerTraits>::bIsPointer); + always_check((CSameAs>::PointerType, TSharedPtr>)); + always_check((CSameAs>::ElementType, int64>)); + always_check(TPointerTraits>::ToAddress(nullptr) == nullptr); + + always_check(TPointerTraits>::bIsPointer); + always_check((CSameAs>::PointerType, TSharedPtr>)); + always_check((CSameAs>::ElementType, int64>)); + always_check(TPointerTraits>::ToAddress(nullptr) == nullptr); + +} + +NAMESPACE_UNNAMED_BEGIN + +struct FCounter +{ + static int32 Num; + FCounter() { ++Num; } + ~FCounter() { --Num; } +}; + +int32 FCounter::Num = 0; + +struct FDeleter +{ + static int32 Num; + void operator()(FCounter* Ptr) { delete Ptr; ++Num; } +}; + +int32 FDeleter::Num = 0; + +struct FArrayDeleter +{ + static int32 Num; + void operator()(FCounter* Ptr) { delete [] Ptr; ++Num; } +}; + +int32 FArrayDeleter::Num = 0; + +NAMESPACE_UNNAMED_END + +void TestUniquePointer() +{ + { + TUniqueRef Temp(new int32); + *Temp = 15; + always_check(*Temp.Get() = 15); + } + + FCounter::Num = 0; + FDeleter::Num = 0; + + { + FCounter* PtrA = new FCounter; + FCounter* PtrB = new FCounter; + FCounter* PtrC = new FCounter; + + TUniqueRef TempA(PtrA); + TUniqueRef TempB(PtrB); + TUniqueRef TempC(PtrC, FDeleter()); + + always_check(TempA == PtrA); + always_check(TempC != TempB); + always_check((TempA <=> PtrA) == strong_ordering::equal); + always_check((TempC <=> TempB) != strong_ordering::equal); + + int32 TempNum; + + TempNum = FCounter::Num; + TempB.Reset(new FCounter); + always_check(FCounter::Num == TempNum); + + TempNum = FCounter::Num; + TempB.Reset(new FCounter, FDeleter()); + always_check(FCounter::Num == TempNum); + + TempNum = FCounter::Num; + FCounter* PtrX = TempB.ReleaseAndReset(new FCounter); + always_check(FCounter::Num == TempNum + 1); + delete PtrX; + + TempNum = FCounter::Num; + FCounter* PtrY = TempB.ReleaseAndReset(new FCounter, FDeleter()); + always_check(FCounter::Num == TempNum + 1); + delete PtrY; + + always_check(GetTypeHash(TempB) == GetTypeHash(TempB.Get())); + + Swap(TempB, TempC); + + always_check(TempC.GetDeleter().Num == 2); + } + + always_check(FCounter::Num == 0); + always_check(FDeleter::Num == 4); + + { + TUniqueRef Temp(new int32[4]); + Temp[0] = 15; + always_check(Temp.Get()[0] = 15); + } + + FCounter::Num = 0; + FArrayDeleter::Num = 0; + + { + FCounter* PtrA = new FCounter[4]; + FCounter* PtrB = new FCounter[4]; + FCounter* PtrC = new FCounter[4]; + + TUniqueRef TempA(PtrA); + TUniqueRef TempB(PtrB); + TUniqueRef TempC(PtrC, FArrayDeleter()); + + always_check(TempA == PtrA); + always_check(TempC != TempB); + always_check((TempA <=> PtrA) == strong_ordering::equal); + always_check((TempC <=> TempB) != strong_ordering::equal); + + int32 TempNum; + + TempNum = FCounter::Num; + TempB.Reset(new FCounter[4]); + always_check(FCounter::Num == TempNum); + + TempNum = FCounter::Num; + TempB.Reset(new FCounter[4], FArrayDeleter()); + always_check(FCounter::Num == TempNum); + + TempNum = FCounter::Num; + FCounter* PtrX = TempB.ReleaseAndReset(new FCounter[4]); + always_check(FCounter::Num == TempNum + 4); + delete [] PtrX; + + TempNum = FCounter::Num; + FCounter* PtrY = TempB.ReleaseAndReset(new FCounter[4], FArrayDeleter()); + always_check(FCounter::Num == TempNum + 4); + delete [] PtrY; + + always_check(GetTypeHash(TempB) == GetTypeHash(TempB.Get())); + + Swap(TempB, TempC); + + always_check(TempC.GetDeleter().Num == 2); + } + + always_check( FCounter::Num == 0); + always_check(FArrayDeleter::Num == 4); + + { + TUniquePtr Temp = MakeUnique(NoInit); + *Temp = 15; + always_check(*Temp.Get() = 15); + } + + { + TUniquePtr Temp = MakeUnique(); + *Temp = 15; + always_check(*Temp.Get() = 15); + } + + FCounter::Num = 0; + FDeleter::Num = 0; + + { + FCounter* PtrA = new FCounter; + FCounter* PtrB = new FCounter; + FCounter* PtrC = new FCounter; + + TUniquePtr TempA(PtrA); + TUniquePtr TempB(PtrB); + TUniquePtr TempC(PtrC, FDeleter()); + + always_check(TempA == PtrA); + always_check(TempC != TempB); + always_check((TempA <=> PtrA) == strong_ordering::equal); + always_check((TempC <=> TempB) != strong_ordering::equal); + + int32 TempNum; + + TempNum = FCounter::Num; + TempB.Reset(new FCounter); + always_check(FCounter::Num == TempNum); + + TempNum = FCounter::Num; + TempB.Reset(new FCounter, FDeleter()); + always_check(FCounter::Num == TempNum); + + TempNum = FCounter::Num; + FCounter* PtrX = TempB.ReleaseAndReset(new FCounter); + always_check(FCounter::Num == TempNum + 1); + delete PtrX; + + TempNum = FCounter::Num; + FCounter* PtrY = TempB.ReleaseAndReset(new FCounter, FDeleter()); + always_check(FCounter::Num == TempNum + 1); + delete PtrY; + + always_check(GetTypeHash(TempB) == GetTypeHash(TempB.Get())); + + Swap(TempB, TempC); + + always_check(TempC.GetDeleter().Num == 2); + + TUniquePtr TempD(MoveTemp(TempB)); + + TUniquePtr TempE; + TempE = MoveTemp(TempC); + TempE = nullptr; + + TempB.Reset(new FCounter); + always_check(!!TempB); + always_check(TempB.IsValid()); + delete TempB.Release(); + + } + + always_check(FCounter::Num == 0); + always_check(FDeleter::Num == 4); + + { + TUniquePtr Temp = MakeUnique(4, NoInit); + Temp[0] = 15; + always_check(Temp.Get()[0] = 15); + } + + { + TUniquePtr Temp = MakeUnique(4); + Temp[0] = 15; + always_check(Temp.Get()[0] = 15); + } + + FCounter::Num = 0; + FArrayDeleter::Num = 0; + + { + FCounter* PtrA = new FCounter[4]; + FCounter* PtrB = new FCounter[4]; + FCounter* PtrC = new FCounter[4]; + + TUniquePtr TempA(PtrA); + TUniquePtr TempB(PtrB); + TUniquePtr TempC(PtrC, FArrayDeleter()); + + always_check(TempA == PtrA); + always_check(TempC != TempB); + always_check((TempA <=> PtrA) == strong_ordering::equal); + always_check((TempC <=> TempB) != strong_ordering::equal); + + int32 TempNum; + + TempNum = FCounter::Num; + TempB.Reset(new FCounter[4]); + always_check(FCounter::Num == TempNum); + + TempNum = FCounter::Num; + TempB.Reset(new FCounter[4], FArrayDeleter()); + always_check(FCounter::Num == TempNum); + + TempNum = FCounter::Num; + FCounter* PtrX = TempB.ReleaseAndReset(new FCounter[4]); + always_check(FCounter::Num == TempNum + 4); + delete [] PtrX; + + TempNum = FCounter::Num; + FCounter* PtrY = TempB.ReleaseAndReset(new FCounter[4], FArrayDeleter()); + always_check(FCounter::Num == TempNum + 4); + delete [] PtrY; + + always_check(GetTypeHash(TempB) == GetTypeHash(TempB.Get())); + + Swap(TempB, TempC); + + always_check(TempC.GetDeleter().Num == 2); + + TUniquePtr TempD(MoveTemp(TempB)); + + TUniquePtr TempE; + TempE = MoveTemp(TempC); + TempE = nullptr; + + TempB.Reset(new FCounter[4]); + always_check(!!TempB); + always_check(TempB.IsValid()); + delete [] TempB.Release(); + + } + + always_check( FCounter::Num == 0); + always_check(FArrayDeleter::Num == 4); + + { + TUniquePtr TempA; + TUniquePtr TempB = MoveTemp(TempA); + TUniquePtr TempC; + TempC = MoveTemp(TempA); + } + + { + TUniquePtr TempA; + TUniquePtr TempB = MoveTemp(TempA); + TUniquePtr TempC; + TempC = MoveTemp(TempA); + } + +} + +void TestSharedPointer() +{ + + FCounter::Num = 0; + FDeleter::Num = 0; + + { + FCounter* PtrA = new FCounter; + FCounter* PtrB = new FCounter; + FCounter* PtrC = new FCounter; + + TSharedRef TempA(PtrA); + TSharedRef TempB(PtrB, FDeleter()); + TSharedRef TempC(PtrC, FDeleter()); + + always_check(TempA == PtrA); + always_check(TempC != TempB); + always_check((TempA <=> PtrA) == strong_ordering::equal); + always_check((TempC <=> TempB) != strong_ordering::equal); + + int32 TempNum; + + TempNum = FCounter::Num; + TempB.Reset(new FCounter, FDeleter()); + always_check(FCounter::Num == TempNum); + + TempNum = FCounter::Num; + TempC.Reset(new FCounter, FDeleter()); + always_check(FCounter::Num == TempNum); + + always_check(GetTypeHash(TempB) == GetTypeHash(TempB.Get())); + + Swap(TempB, TempC); + + always_check(TempA.GetDeleter() == nullptr); + always_check(TempC.GetDeleter() != nullptr); + always_check(TempC.GetDeleter()->Num == 2); + + TSharedRef TempD(MoveTemp(TempB)); + } + + always_check(FCounter::Num == 0); + always_check(FDeleter::Num == 4); + + { + TSharedRef Temp = MakeShared(4, NoInit); + Temp[0] = 15; + always_check(Temp.Get()[0] = 15); + } + + { + TSharedRef Temp = MakeShared(4); + Temp[0] = 15; + always_check(Temp.Get()[0] = 15); + } + + FCounter::Num = 0; + FArrayDeleter::Num = 0; + + { + FCounter* PtrA = new FCounter[4]; + FCounter* PtrB = new FCounter[4]; + FCounter* PtrC = new FCounter[4]; + + TSharedRef TempA(PtrA); + TSharedRef TempB(PtrB, FArrayDeleter()); + TSharedRef TempC(PtrC, FArrayDeleter()); + + always_check(TempA == PtrA); + always_check(TempC != TempB); + always_check((TempA <=> PtrA) == strong_ordering::equal); + always_check((TempC <=> TempB) != strong_ordering::equal); + + int32 TempNum; + + TempNum = FCounter::Num; + TempB.Reset(new FCounter[4], FArrayDeleter()); + always_check(FCounter::Num == TempNum); + + TempNum = FCounter::Num; + TempB.Reset(new FCounter[4], FArrayDeleter()); + always_check(FCounter::Num == TempNum); + + always_check(GetTypeHash(TempB) == GetTypeHash(TempB.Get())); + + Swap(TempB, TempC); + + always_check(TempA.GetDeleter() == nullptr); + always_check(TempC.GetDeleter() != nullptr); + always_check(TempC.GetDeleter()->Num == 2); + + TSharedRef TempD(MoveTemp(TempB)); + } + + always_check( FCounter::Num == 0); + always_check(FArrayDeleter::Num == 4); + + FCounter::Num = 0; + FDeleter::Num = 0; + + { + FCounter* PtrA = new FCounter; + FCounter* PtrB = new FCounter; + FCounter* PtrC = new FCounter; + + TSharedPtr TempA(PtrA); + TSharedPtr TempB(PtrB, FDeleter()); + TSharedPtr TempC(PtrC, FDeleter()); + + always_check(TempA == PtrA); + always_check(TempC != TempB); + always_check((TempA <=> PtrA) == strong_ordering::equal); + always_check((TempC <=> TempB) != strong_ordering::equal); + + int32 TempNum; + + TempNum = FCounter::Num; + TempB.Reset(new FCounter, FDeleter()); + always_check(FCounter::Num == TempNum); + + TempNum = FCounter::Num; + TempB.Reset(new FCounter, FDeleter()); + always_check(FCounter::Num == TempNum); + + always_check(GetTypeHash(TempB) == GetTypeHash(TempB.Get())); + + Swap(TempB, TempC); + + always_check(TempA.GetDeleter() == nullptr); + always_check(TempC.GetDeleter() != nullptr); + always_check(TempC.GetDeleter()->Num == 2); + + TSharedPtr TempD(MoveTemp(TempB)); + + TSharedPtr TempE; + TempE = MoveTemp(TempC); + TempE = nullptr; + + TempB.Reset(new FCounter, FDeleter()); + always_check(!!TempB); + always_check(TempB.IsValid()); + + } + + always_check(FCounter::Num == 0); + always_check(FDeleter::Num == 5); + + { + TSharedPtr Temp = MakeShared(4, NoInit); + Temp[0] = 15; + always_check(Temp.Get()[0] = 15); + } + + { + TSharedPtr Temp = MakeShared(4); + Temp[0] = 15; + always_check(Temp.Get()[0] = 15); + } + + FCounter::Num = 0; + FArrayDeleter::Num = 0; + + { + FCounter* PtrA = new FCounter[4]; + FCounter* PtrB = new FCounter[4]; + FCounter* PtrC = new FCounter[4]; + + TSharedPtr TempA(PtrA); + TSharedPtr TempB(PtrB, FArrayDeleter()); + TSharedPtr TempC(PtrC, FArrayDeleter()); + + always_check(TempA == PtrA); + always_check(TempC != TempB); + always_check((TempA <=> PtrA) == strong_ordering::equal); + always_check((TempC <=> TempB) != strong_ordering::equal); + + int32 TempNum; + + TempNum = FCounter::Num; + TempB.Reset(new FCounter[4], FArrayDeleter()); + always_check(FCounter::Num == TempNum); + + TempNum = FCounter::Num; + TempB.Reset(new FCounter[4], FArrayDeleter()); + always_check(FCounter::Num == TempNum); + + always_check(GetTypeHash(TempB) == GetTypeHash(TempB.Get())); + + Swap(TempB, TempC); + + always_check(TempA.GetDeleter() == nullptr); + always_check(TempC.GetDeleter() != nullptr); + always_check(TempC.GetDeleter()->Num == 2); + + TSharedPtr TempD(MoveTemp(TempB)); + + TSharedPtr TempE; + TempE = MoveTemp(TempC); + TempE = nullptr; + + TempB.Reset(new FCounter[4], FArrayDeleter()); + always_check(!!TempB); + always_check(TempB.IsValid()); + + } + + always_check( FCounter::Num == 0); + always_check(FArrayDeleter::Num == 5); + + { + TSharedPtr Temp; + always_check(!Temp.IsValid()); + if (Temp.Get() == nullptr) { } + } + + { + TSharedPtr Temp(new int32(123)); + + always_check(Temp.IsValid()); + always_check(Temp.IsUnique()); + + const int32 DeferenceTest = *Temp; + + Temp.Reset(); + + always_check(Temp.GetSharedReferenceCount() == 0); + } + + { + TSharedPtr TempA(new bool(false)); + TSharedPtr TempB(TempA); + } + + { + TSharedPtr TempA(new bool(false)); + TSharedPtr TempB; + TempB = TempA; + } + + { + struct FSharedTest { bool bTest; }; + + TSharedPtr TempA(new FSharedTest()); + + TempA->bTest = true; + + (*TempA).bTest = false; + + TSharedPtr TempB(TempA); + + TempA.Reset(); + } + + { + class FBase { bool bTest; }; + + class FDerived : public FBase { }; + + { + TSharedPtr TempA(new FDerived()); + TSharedPtr TempB(StaticCast(TempA)); + } + + { + TSharedPtr TempA(new FDerived()); + TSharedPtr TempB(TempA); + } + + { + TSharedPtr TempA(new FDerived()); + TSharedPtr TempB; + TempB = TempA; + } + } + + { + bool* Ptr = nullptr; + TSharedPtr Temp(Ptr); + always_check(!Temp.IsValid()); + } + + { + TSharedPtr Temp(new bool(true)); + always_check(Temp.IsValid()); + } + + { + TWeakPtr Temp; + always_check(!Temp.Lock().IsValid()); + } + + { + TSharedPtr TempShared(new int32(64)); + TWeakPtr TempWeak(TempShared); + always_check(TempWeak.Lock().IsValid()); + } + + { + TSharedPtr TempShared(new int32(64)); + TWeakPtr TempWeak; + TempWeak = TempShared; + + always_check(TempWeak.Lock().IsValid()); + + TempWeak.Reset(); + always_check(!TempWeak.Lock().IsValid()); + } + + { + TSharedPtr TempShared(new int32(64)); + TWeakPtr TempWeak = TempShared; + TempShared.Reset(); + always_check(!TempWeak.Lock().IsValid()); + } + + { + TSharedPtr TempA(new int32(64)); + TSharedPtr TempB(new int32(21)); + TSharedPtr TempC(TempB); + + always_check(!(TempA == TempB)); + always_check(TempA != TempB); + always_check(TempB == TempC); + } + + { + TSharedPtr TempA(new int32(64)); + TSharedPtr TempB(new int32(21)); + + TWeakPtr WeakA(TempA); + TWeakPtr WeakB(TempB); + TWeakPtr WeakC(TempB); + + always_check(!(WeakA.Lock() == WeakB.Lock())); + always_check(WeakA.Lock() != WeakB.Lock()); + always_check(WeakB.Lock() == WeakC.Lock()); + } + + { + TSharedPtr TempA(new int32(10)); + TSharedPtr TempB(new float32(1.0f)); + TSharedPtr TempC(new float32(2.0f)); + + if (TempB == TempC) { } + + TempB = TempC; + + TSharedPtr TempD(new float32(123.0f)); + + TempB = TempD; + + TWeakPtr TempE = TempB; + TWeakPtr TempF; + + TempF = ConstCast(TempC); + *TempF.Lock() = 20.0f; + } + + { + TSharedPtr Temp; + struct FTest { int32 Value; }; + Temp = TSharedPtr(new FTest()); + Temp->Value = 20; + } + + { + TSharedPtr TempA(nullptr); + TSharedPtr TempB = nullptr; + + TWeakPtr TempD(nullptr); + TWeakPtr TempE = nullptr; + + TempB = TSharedPtr(new float32(0.1f)); + TempB = nullptr; + + TempB = MakeShared(30.0f); + TSharedPtr TempC(MakeShared(2.0)); + + struct FTest + { + TSharedPtr Value; + + TSharedPtr FuncA() { return Value; } + + TSharedPtr FuncB() { return MakeShared(123.0f); } + }; + } + + { + TSharedRef Temp(new float32(123.0f)); + } + + { + TSharedRef Temp(new float32(123.0f)); + const float& RefA = *Temp; + const float& RefB = *Temp.Get(); + } + + { + TSharedRef Temp = MakeShared(123.0f); + } + + { + TSharedRef TempA(new int32(1)); + TSharedPtr TempB(TempA); + } + + { + TSharedPtr TempA(new int32(1)); + TSharedRef TempB(TempA.ToSharedRef()); + } + + { + TSharedRef Temp(new int32(10)); + Temp = TSharedRef(new int32(20)); + } + + { + TSharedRef TempA(new int32(99)); + TWeakPtr TempB = TempA; + always_check(TempB.Lock()); + } + + { + TSharedRef IntRef1(new int32(99)); + TSharedRef IntRef2(new int32(21)); + always_check(!(IntRef1 == IntRef2)); + always_check(IntRef1 != IntRef2); + } + + { + TSharedRef TempA(new int32(21)); + TSharedPtr TempB(TempA); + TSharedPtr TempC; + + always_check(TempA == TempB && TempB == TempA); + always_check(!(TempA != TempB || TempB != TempA)); + always_check(!(TempA == TempC) && (TempA != TempC)); + } + + { + struct FTest : public TSharedFromThis + { + TSharedRef FuncTest() { return AsShared(); } + }; + + TSharedPtr TempA(new FTest()); + + { + FTest* Ptr = TempA.Get(); + TSharedRef TempB(Ptr->FuncTest()); + } + } + + { + TSharedRef TempA = MakeShared(); + TSharedRef TempB = TempA; + TSharedRef TempC = MakeShared(); + TempC = TempA; + } + + { + TSharedRef TempA = MakeShared(4); + TSharedRef TempB = TempA; + TSharedRef TempC = MakeShared(4); + TempC = TempA; + } + + { + TSharedPtr TempA; + TSharedPtr TempB = TempA; + TSharedPtr TempC; + TempC = TempA; + } + + { + TSharedPtr TempA; + TSharedPtr TempB = TempA; + TSharedPtr TempC; + TempC = TempA; + } + + { + TWeakPtr TempA; + TWeakPtr TempB = TempA; + TWeakPtr TempC; + TempC = TempA; + } + + { + TWeakPtr TempA; + TWeakPtr TempB = TempA; + TWeakPtr TempC; + TempC = TempA; + } + +} + NAMESPACE_END(Testing) NAMESPACE_MODULE_END(Utility) diff --git a/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp index beb1ae7..e6fc6d6 100644 --- a/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp @@ -25,8 +25,6 @@ void TestTemplates() TestFunction(); TestAtomic(); TestScopeHelper(); - TestUniquePointer(); - TestSharedPointer(); TestMiscTemplates(); } @@ -1473,799 +1471,6 @@ void TestScopeHelper() NAMESPACE_UNNAMED_BEGIN -struct FCounter -{ - static int32 Num; - FCounter() { ++Num; } - ~FCounter() { --Num; } -}; - -int32 FCounter::Num = 0; - -struct FDeleter -{ - static int32 Num; - void operator()(FCounter* Ptr) { delete Ptr; ++Num; } -}; - -int32 FDeleter::Num = 0; - -struct FArrayDeleter -{ - static int32 Num; - void operator()(FCounter* Ptr) { delete [] Ptr; ++Num; } -}; - -int32 FArrayDeleter::Num = 0; - -NAMESPACE_UNNAMED_END - -void TestUniquePointer() -{ - { - TUniqueRef Temp(new int32); - *Temp = 15; - always_check(*Temp.Get() = 15); - } - - FCounter::Num = 0; - FDeleter::Num = 0; - - { - FCounter* PtrA = new FCounter; - FCounter* PtrB = new FCounter; - FCounter* PtrC = new FCounter; - - TUniqueRef TempA(PtrA); - TUniqueRef TempB(PtrB); - TUniqueRef TempC(PtrC, FDeleter()); - - always_check(TempA == PtrA); - always_check(TempC != TempB); - always_check((TempA <=> PtrA) == strong_ordering::equal); - always_check((TempC <=> TempB) != strong_ordering::equal); - - int32 TempNum; - - TempNum = FCounter::Num; - TempB.Reset(new FCounter); - always_check(FCounter::Num == TempNum); - - TempNum = FCounter::Num; - TempB.Reset(new FCounter, FDeleter()); - always_check(FCounter::Num == TempNum); - - TempNum = FCounter::Num; - FCounter* PtrX = TempB.ReleaseAndReset(new FCounter); - always_check(FCounter::Num == TempNum + 1); - delete PtrX; - - TempNum = FCounter::Num; - FCounter* PtrY = TempB.ReleaseAndReset(new FCounter, FDeleter()); - always_check(FCounter::Num == TempNum + 1); - delete PtrY; - - always_check(GetTypeHash(TempB) == GetTypeHash(TempB.Get())); - - Swap(TempB, TempC); - - always_check(TempC.GetDeleter().Num == 2); - } - - always_check(FCounter::Num == 0); - always_check(FDeleter::Num == 4); - - { - TUniqueRef Temp(new int32[4]); - Temp[0] = 15; - always_check(Temp.Get()[0] = 15); - } - - FCounter::Num = 0; - FArrayDeleter::Num = 0; - - { - FCounter* PtrA = new FCounter[4]; - FCounter* PtrB = new FCounter[4]; - FCounter* PtrC = new FCounter[4]; - - TUniqueRef TempA(PtrA); - TUniqueRef TempB(PtrB); - TUniqueRef TempC(PtrC, FArrayDeleter()); - - always_check(TempA == PtrA); - always_check(TempC != TempB); - always_check((TempA <=> PtrA) == strong_ordering::equal); - always_check((TempC <=> TempB) != strong_ordering::equal); - - int32 TempNum; - - TempNum = FCounter::Num; - TempB.Reset(new FCounter[4]); - always_check(FCounter::Num == TempNum); - - TempNum = FCounter::Num; - TempB.Reset(new FCounter[4], FArrayDeleter()); - always_check(FCounter::Num == TempNum); - - TempNum = FCounter::Num; - FCounter* PtrX = TempB.ReleaseAndReset(new FCounter[4]); - always_check(FCounter::Num == TempNum + 4); - delete [] PtrX; - - TempNum = FCounter::Num; - FCounter* PtrY = TempB.ReleaseAndReset(new FCounter[4], FArrayDeleter()); - always_check(FCounter::Num == TempNum + 4); - delete [] PtrY; - - always_check(GetTypeHash(TempB) == GetTypeHash(TempB.Get())); - - Swap(TempB, TempC); - - always_check(TempC.GetDeleter().Num == 2); - } - - always_check( FCounter::Num == 0); - always_check(FArrayDeleter::Num == 4); - - { - TUniquePtr Temp = MakeUnique(NoInit); - *Temp = 15; - always_check(*Temp.Get() = 15); - } - - { - TUniquePtr Temp = MakeUnique(); - *Temp = 15; - always_check(*Temp.Get() = 15); - } - - FCounter::Num = 0; - FDeleter::Num = 0; - - { - FCounter* PtrA = new FCounter; - FCounter* PtrB = new FCounter; - FCounter* PtrC = new FCounter; - - TUniquePtr TempA(PtrA); - TUniquePtr TempB(PtrB); - TUniquePtr TempC(PtrC, FDeleter()); - - always_check(TempA == PtrA); - always_check(TempC != TempB); - always_check((TempA <=> PtrA) == strong_ordering::equal); - always_check((TempC <=> TempB) != strong_ordering::equal); - - int32 TempNum; - - TempNum = FCounter::Num; - TempB.Reset(new FCounter); - always_check(FCounter::Num == TempNum); - - TempNum = FCounter::Num; - TempB.Reset(new FCounter, FDeleter()); - always_check(FCounter::Num == TempNum); - - TempNum = FCounter::Num; - FCounter* PtrX = TempB.ReleaseAndReset(new FCounter); - always_check(FCounter::Num == TempNum + 1); - delete PtrX; - - TempNum = FCounter::Num; - FCounter* PtrY = TempB.ReleaseAndReset(new FCounter, FDeleter()); - always_check(FCounter::Num == TempNum + 1); - delete PtrY; - - always_check(GetTypeHash(TempB) == GetTypeHash(TempB.Get())); - - Swap(TempB, TempC); - - always_check(TempC.GetDeleter().Num == 2); - - TUniquePtr TempD(MoveTemp(TempB)); - - TUniquePtr TempE; - TempE = MoveTemp(TempC); - TempE = nullptr; - - TempB.Reset(new FCounter); - always_check(!!TempB); - always_check(TempB.IsValid()); - delete TempB.Release(); - - } - - always_check(FCounter::Num == 0); - always_check(FDeleter::Num == 4); - - { - TUniquePtr Temp = MakeUnique(4, NoInit); - Temp[0] = 15; - always_check(Temp.Get()[0] = 15); - } - - { - TUniquePtr Temp = MakeUnique(4); - Temp[0] = 15; - always_check(Temp.Get()[0] = 15); - } - - FCounter::Num = 0; - FArrayDeleter::Num = 0; - - { - FCounter* PtrA = new FCounter[4]; - FCounter* PtrB = new FCounter[4]; - FCounter* PtrC = new FCounter[4]; - - TUniquePtr TempA(PtrA); - TUniquePtr TempB(PtrB); - TUniquePtr TempC(PtrC, FArrayDeleter()); - - always_check(TempA == PtrA); - always_check(TempC != TempB); - always_check((TempA <=> PtrA) == strong_ordering::equal); - always_check((TempC <=> TempB) != strong_ordering::equal); - - int32 TempNum; - - TempNum = FCounter::Num; - TempB.Reset(new FCounter[4]); - always_check(FCounter::Num == TempNum); - - TempNum = FCounter::Num; - TempB.Reset(new FCounter[4], FArrayDeleter()); - always_check(FCounter::Num == TempNum); - - TempNum = FCounter::Num; - FCounter* PtrX = TempB.ReleaseAndReset(new FCounter[4]); - always_check(FCounter::Num == TempNum + 4); - delete [] PtrX; - - TempNum = FCounter::Num; - FCounter* PtrY = TempB.ReleaseAndReset(new FCounter[4], FArrayDeleter()); - always_check(FCounter::Num == TempNum + 4); - delete [] PtrY; - - always_check(GetTypeHash(TempB) == GetTypeHash(TempB.Get())); - - Swap(TempB, TempC); - - always_check(TempC.GetDeleter().Num == 2); - - TUniquePtr TempD(MoveTemp(TempB)); - - TUniquePtr TempE; - TempE = MoveTemp(TempC); - TempE = nullptr; - - TempB.Reset(new FCounter[4]); - always_check(!!TempB); - always_check(TempB.IsValid()); - delete [] TempB.Release(); - - } - - always_check( FCounter::Num == 0); - always_check(FArrayDeleter::Num == 4); - - { - TUniquePtr TempA; - TUniquePtr TempB = MoveTemp(TempA); - TUniquePtr TempC; - TempC = MoveTemp(TempA); - } - - { - TUniquePtr TempA; - TUniquePtr TempB = MoveTemp(TempA); - TUniquePtr TempC; - TempC = MoveTemp(TempA); - } - -} - -void TestSharedPointer() -{ - - FCounter::Num = 0; - FDeleter::Num = 0; - - { - FCounter* PtrA = new FCounter; - FCounter* PtrB = new FCounter; - FCounter* PtrC = new FCounter; - - TSharedRef TempA(PtrA); - TSharedRef TempB(PtrB, FDeleter()); - TSharedRef TempC(PtrC, FDeleter()); - - always_check(TempA == PtrA); - always_check(TempC != TempB); - always_check((TempA <=> PtrA) == strong_ordering::equal); - always_check((TempC <=> TempB) != strong_ordering::equal); - - int32 TempNum; - - TempNum = FCounter::Num; - TempB.Reset(new FCounter, FDeleter()); - always_check(FCounter::Num == TempNum); - - TempNum = FCounter::Num; - TempC.Reset(new FCounter, FDeleter()); - always_check(FCounter::Num == TempNum); - - always_check(GetTypeHash(TempB) == GetTypeHash(TempB.Get())); - - Swap(TempB, TempC); - - always_check(TempA.GetDeleter() == nullptr); - always_check(TempC.GetDeleter() != nullptr); - always_check(TempC.GetDeleter()->Num == 2); - - TSharedRef TempD(MoveTemp(TempB)); - } - - always_check(FCounter::Num == 0); - always_check(FDeleter::Num == 4); - - { - TSharedRef Temp = MakeShared(4, NoInit); - Temp[0] = 15; - always_check(Temp.Get()[0] = 15); - } - - { - TSharedRef Temp = MakeShared(4); - Temp[0] = 15; - always_check(Temp.Get()[0] = 15); - } - - FCounter::Num = 0; - FArrayDeleter::Num = 0; - - { - FCounter* PtrA = new FCounter[4]; - FCounter* PtrB = new FCounter[4]; - FCounter* PtrC = new FCounter[4]; - - TSharedRef TempA(PtrA); - TSharedRef TempB(PtrB, FArrayDeleter()); - TSharedRef TempC(PtrC, FArrayDeleter()); - - always_check(TempA == PtrA); - always_check(TempC != TempB); - always_check((TempA <=> PtrA) == strong_ordering::equal); - always_check((TempC <=> TempB) != strong_ordering::equal); - - int32 TempNum; - - TempNum = FCounter::Num; - TempB.Reset(new FCounter[4], FArrayDeleter()); - always_check(FCounter::Num == TempNum); - - TempNum = FCounter::Num; - TempB.Reset(new FCounter[4], FArrayDeleter()); - always_check(FCounter::Num == TempNum); - - always_check(GetTypeHash(TempB) == GetTypeHash(TempB.Get())); - - Swap(TempB, TempC); - - always_check(TempA.GetDeleter() == nullptr); - always_check(TempC.GetDeleter() != nullptr); - always_check(TempC.GetDeleter()->Num == 2); - - TSharedRef TempD(MoveTemp(TempB)); - } - - always_check( FCounter::Num == 0); - always_check(FArrayDeleter::Num == 4); - - FCounter::Num = 0; - FDeleter::Num = 0; - - { - FCounter* PtrA = new FCounter; - FCounter* PtrB = new FCounter; - FCounter* PtrC = new FCounter; - - TSharedPtr TempA(PtrA); - TSharedPtr TempB(PtrB, FDeleter()); - TSharedPtr TempC(PtrC, FDeleter()); - - always_check(TempA == PtrA); - always_check(TempC != TempB); - always_check((TempA <=> PtrA) == strong_ordering::equal); - always_check((TempC <=> TempB) != strong_ordering::equal); - - int32 TempNum; - - TempNum = FCounter::Num; - TempB.Reset(new FCounter, FDeleter()); - always_check(FCounter::Num == TempNum); - - TempNum = FCounter::Num; - TempB.Reset(new FCounter, FDeleter()); - always_check(FCounter::Num == TempNum); - - always_check(GetTypeHash(TempB) == GetTypeHash(TempB.Get())); - - Swap(TempB, TempC); - - always_check(TempA.GetDeleter() == nullptr); - always_check(TempC.GetDeleter() != nullptr); - always_check(TempC.GetDeleter()->Num == 2); - - TSharedPtr TempD(MoveTemp(TempB)); - - TSharedPtr TempE; - TempE = MoveTemp(TempC); - TempE = nullptr; - - TempB.Reset(new FCounter, FDeleter()); - always_check(!!TempB); - always_check(TempB.IsValid()); - - } - - always_check(FCounter::Num == 0); - always_check(FDeleter::Num == 5); - - { - TSharedPtr Temp = MakeShared(4, NoInit); - Temp[0] = 15; - always_check(Temp.Get()[0] = 15); - } - - { - TSharedPtr Temp = MakeShared(4); - Temp[0] = 15; - always_check(Temp.Get()[0] = 15); - } - - FCounter::Num = 0; - FArrayDeleter::Num = 0; - - { - FCounter* PtrA = new FCounter[4]; - FCounter* PtrB = new FCounter[4]; - FCounter* PtrC = new FCounter[4]; - - TSharedPtr TempA(PtrA); - TSharedPtr TempB(PtrB, FArrayDeleter()); - TSharedPtr TempC(PtrC, FArrayDeleter()); - - always_check(TempA == PtrA); - always_check(TempC != TempB); - always_check((TempA <=> PtrA) == strong_ordering::equal); - always_check((TempC <=> TempB) != strong_ordering::equal); - - int32 TempNum; - - TempNum = FCounter::Num; - TempB.Reset(new FCounter[4], FArrayDeleter()); - always_check(FCounter::Num == TempNum); - - TempNum = FCounter::Num; - TempB.Reset(new FCounter[4], FArrayDeleter()); - always_check(FCounter::Num == TempNum); - - always_check(GetTypeHash(TempB) == GetTypeHash(TempB.Get())); - - Swap(TempB, TempC); - - always_check(TempA.GetDeleter() == nullptr); - always_check(TempC.GetDeleter() != nullptr); - always_check(TempC.GetDeleter()->Num == 2); - - TSharedPtr TempD(MoveTemp(TempB)); - - TSharedPtr TempE; - TempE = MoveTemp(TempC); - TempE = nullptr; - - TempB.Reset(new FCounter[4], FArrayDeleter()); - always_check(!!TempB); - always_check(TempB.IsValid()); - - } - - always_check( FCounter::Num == 0); - always_check(FArrayDeleter::Num == 5); - - { - TSharedPtr Temp; - always_check(!Temp.IsValid()); - if (Temp.Get() == nullptr) { } - } - - { - TSharedPtr Temp(new int32(123)); - - always_check(Temp.IsValid()); - always_check(Temp.IsUnique()); - - const int32 DeferenceTest = *Temp; - - Temp.Reset(); - - always_check(Temp.GetSharedReferenceCount() == 0); - } - - { - TSharedPtr TempA(new bool(false)); - TSharedPtr TempB(TempA); - } - - { - TSharedPtr TempA(new bool(false)); - TSharedPtr TempB; - TempB = TempA; - } - - { - struct FSharedTest { bool bTest; }; - - TSharedPtr TempA(new FSharedTest()); - - TempA->bTest = true; - - (*TempA).bTest = false; - - TSharedPtr TempB(TempA); - - TempA.Reset(); - } - - { - class FBase { bool bTest; }; - - class FDerived : public FBase { }; - - { - TSharedPtr TempA(new FDerived()); - TSharedPtr TempB(StaticCast(TempA)); - } - - { - TSharedPtr TempA(new FDerived()); - TSharedPtr TempB(TempA); - } - - { - TSharedPtr TempA(new FDerived()); - TSharedPtr TempB; - TempB = TempA; - } - } - - { - bool* Ptr = nullptr; - TSharedPtr Temp(Ptr); - always_check(!Temp.IsValid()); - } - - { - TSharedPtr Temp(new bool(true)); - always_check(Temp.IsValid()); - } - - { - TWeakPtr Temp; - always_check(!Temp.Lock().IsValid()); - } - - { - TSharedPtr TempShared(new int32(64)); - TWeakPtr TempWeak(TempShared); - always_check(TempWeak.Lock().IsValid()); - } - - { - TSharedPtr TempShared(new int32(64)); - TWeakPtr TempWeak; - TempWeak = TempShared; - - always_check(TempWeak.Lock().IsValid()); - - TempWeak.Reset(); - always_check(!TempWeak.Lock().IsValid()); - } - - { - TSharedPtr TempShared(new int32(64)); - TWeakPtr TempWeak = TempShared; - TempShared.Reset(); - always_check(!TempWeak.Lock().IsValid()); - } - - { - TSharedPtr TempA(new int32(64)); - TSharedPtr TempB(new int32(21)); - TSharedPtr TempC(TempB); - - always_check(!(TempA == TempB)); - always_check(TempA != TempB); - always_check(TempB == TempC); - } - - { - TSharedPtr TempA(new int32(64)); - TSharedPtr TempB(new int32(21)); - - TWeakPtr WeakA(TempA); - TWeakPtr WeakB(TempB); - TWeakPtr WeakC(TempB); - - always_check(!(WeakA.Lock() == WeakB.Lock())); - always_check(WeakA.Lock() != WeakB.Lock()); - always_check(WeakB.Lock() == WeakC.Lock()); - } - - { - TSharedPtr TempA(new int32(10)); - TSharedPtr TempB(new float32(1.0f)); - TSharedPtr TempC(new float32(2.0f)); - - if (TempB == TempC) { } - - TempB = TempC; - - TSharedPtr TempD(new float32(123.0f)); - - TempB = TempD; - - TWeakPtr TempE = TempB; - TWeakPtr TempF; - - TempF = ConstCast(TempC); - *TempF.Lock() = 20.0f; - } - - { - TSharedPtr Temp; - struct FTest { int32 Value; }; - Temp = TSharedPtr(new FTest()); - Temp->Value = 20; - } - - { - TSharedPtr TempA(nullptr); - TSharedPtr TempB = nullptr; - - TWeakPtr TempD(nullptr); - TWeakPtr TempE = nullptr; - - TempB = TSharedPtr(new float32(0.1f)); - TempB = nullptr; - - TempB = MakeShared(30.0f); - TSharedPtr TempC(MakeShared(2.0)); - - struct FTest - { - TSharedPtr Value; - - TSharedPtr FuncA() { return Value; } - - TSharedPtr FuncB() { return MakeShared(123.0f); } - }; - } - - { - TSharedRef Temp(new float32(123.0f)); - } - - { - TSharedRef Temp(new float32(123.0f)); - const float& RefA = *Temp; - const float& RefB = *Temp.Get(); - } - - { - TSharedRef Temp = MakeShared(123.0f); - } - - { - TSharedRef TempA(new int32(1)); - TSharedPtr TempB(TempA); - } - - { - TSharedPtr TempA(new int32(1)); - TSharedRef TempB(TempA.ToSharedRef()); - } - - { - TSharedRef Temp(new int32(10)); - Temp = TSharedRef(new int32(20)); - } - - { - TSharedRef TempA(new int32(99)); - TWeakPtr TempB = TempA; - always_check(TempB.Lock()); - } - - { - TSharedRef IntRef1(new int32(99)); - TSharedRef IntRef2(new int32(21)); - always_check(!(IntRef1 == IntRef2)); - always_check(IntRef1 != IntRef2); - } - - { - TSharedRef TempA(new int32(21)); - TSharedPtr TempB(TempA); - TSharedPtr TempC; - - always_check(TempA == TempB && TempB == TempA); - always_check(!(TempA != TempB || TempB != TempA)); - always_check(!(TempA == TempC) && (TempA != TempC)); - } - - { - struct FTest : public TSharedFromThis - { - TSharedRef FuncTest() { return AsShared(); } - }; - - TSharedPtr TempA(new FTest()); - - { - FTest* Ptr = TempA.Get(); - TSharedRef TempB(Ptr->FuncTest()); - } - } - - { - TSharedRef TempA = MakeShared(); - TSharedRef TempB = TempA; - TSharedRef TempC = MakeShared(); - TempC = TempA; - } - - { - TSharedRef TempA = MakeShared(4); - TSharedRef TempB = TempA; - TSharedRef TempC = MakeShared(4); - TempC = TempA; - } - - { - TSharedPtr TempA; - TSharedPtr TempB = TempA; - TSharedPtr TempC; - TempC = TempA; - } - - { - TSharedPtr TempA; - TSharedPtr TempB = TempA; - TSharedPtr TempC; - TempC = TempA; - } - - { - TWeakPtr TempA; - TWeakPtr TempB = TempA; - TWeakPtr TempC; - TempC = TempA; - } - - { - TWeakPtr TempA; - TWeakPtr TempB = TempA; - TWeakPtr TempC; - TempC = TempA; - } - -} - -NAMESPACE_UNNAMED_BEGIN - template struct TTestStructA { @@ -2298,28 +1503,6 @@ void TestMiscTemplates() always_check(TestFunctionB(AddressOf(ObjectA)) == 0); always_check(AddressOf(TestMiscTemplates) == &TestMiscTemplates); - always_check(!TPointerTraits::bIsPointer); - - always_check(TPointerTraits::bIsPointer); - always_check((CSameAs::PointerType, int64*>)); - always_check((CSameAs::ElementType, int64>)); - always_check(TPointerTraits::ToAddress(nullptr) == nullptr); - - always_check(TPointerTraits::bIsPointer); - always_check((CSameAs::PointerType, int64(*)[]>)); - always_check((CSameAs::ElementType, int64>)); - always_check(TPointerTraits::ToAddress(nullptr) == nullptr); - - always_check(TPointerTraits>::bIsPointer); - always_check((CSameAs>::PointerType, TSharedPtr>)); - always_check((CSameAs>::ElementType, int64>)); - always_check(TPointerTraits>::ToAddress(nullptr) == nullptr); - - always_check(TPointerTraits>::bIsPointer); - always_check((CSameAs>::PointerType, TSharedPtr>)); - always_check((CSameAs>::ElementType, int64>)); - always_check(TPointerTraits>::ToAddress(nullptr) == nullptr); - } NAMESPACE_END(Testing) diff --git a/Redcraft.Utility/Source/Public/Templates/PointerTraits.h b/Redcraft.Utility/Source/Public/Memory/PointerTraits.h similarity index 100% rename from Redcraft.Utility/Source/Public/Templates/PointerTraits.h rename to Redcraft.Utility/Source/Public/Memory/PointerTraits.h diff --git a/Redcraft.Utility/Source/Public/Templates/SharedPointer.h b/Redcraft.Utility/Source/Public/Memory/SharedPointer.h similarity index 99% rename from Redcraft.Utility/Source/Public/Templates/SharedPointer.h rename to Redcraft.Utility/Source/Public/Memory/SharedPointer.h index 4c6db25..7bbc91e 100644 --- a/Redcraft.Utility/Source/Public/Templates/SharedPointer.h +++ b/Redcraft.Utility/Source/Public/Memory/SharedPointer.h @@ -5,14 +5,13 @@ #include "Templates/Atomic.h" #include "Templates/Invoke.h" #include "Templates/Utility.h" +#include "Templates/TypeHash.h" +#include "Memory/PointerTraits.h" +#include "Memory/UniquePointer.h" #include "Memory/MemoryOperator.h" #include "Templates/Noncopyable.h" -#include "TypeTraits/PrimaryType.h" -#include "Templates/PointerTraits.h" -#include "Templates/UniquePointer.h" -#include "TypeTraits/Miscellaneous.h" -#include "TypeTraits/TypeProperties.h" -#include "TypeTraits/SupportedOperations.h" +#include "TypeTraits/TypeTraits.h" +#include "Miscellaneous/Compare.h" NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) diff --git a/Redcraft.Utility/Source/Public/Templates/UniquePointer.h b/Redcraft.Utility/Source/Public/Memory/UniquePointer.h similarity index 99% rename from Redcraft.Utility/Source/Public/Templates/UniquePointer.h rename to Redcraft.Utility/Source/Public/Memory/UniquePointer.h index e1e2e46..501df78 100644 --- a/Redcraft.Utility/Source/Public/Templates/UniquePointer.h +++ b/Redcraft.Utility/Source/Public/Memory/UniquePointer.h @@ -3,12 +3,11 @@ #include "CoreTypes.h" #include "Templates/Invoke.h" #include "Templates/Utility.h" +#include "Templates/TypeHash.h" +#include "Memory/PointerTraits.h" #include "Templates/Noncopyable.h" -#include "TypeTraits/PrimaryType.h" -#include "Templates/PointerTraits.h" -#include "TypeTraits/Miscellaneous.h" -#include "TypeTraits/TypeProperties.h" -#include "TypeTraits/SupportedOperations.h" +#include "TypeTraits/TypeTraits.h" +#include "Miscellaneous/Compare.h" NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) diff --git a/Redcraft.Utility/Source/Public/Templates/Any.h b/Redcraft.Utility/Source/Public/Templates/Any.h index b27a7ad..93abb01 100644 --- a/Redcraft.Utility/Source/Public/Templates/Any.h +++ b/Redcraft.Utility/Source/Public/Templates/Any.h @@ -6,6 +6,7 @@ #include "Templates/Utility.h" #include "Templates/TypeHash.h" #include "TypeTraits/TypeTraits.h" +#include "Miscellaneous/Compare.h" #include "Miscellaneous/AssertionMacros.h" NAMESPACE_REDCRAFT_BEGIN diff --git a/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h b/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h index 6a3c610..43684f8 100644 --- a/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h +++ b/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h @@ -4,6 +4,7 @@ #include "Templates/Invoke.h" #include "Templates/Utility.h" #include "Templates/Optional.h" +#include "Templates/TypeHash.h" #include "TypeTraits/TypeTraits.h" NAMESPACE_REDCRAFT_BEGIN diff --git a/Redcraft.Utility/Source/Public/Templates/Templates.h b/Redcraft.Utility/Source/Public/Templates/Templates.h index 0b9c1a5..7e3c0aa 100644 --- a/Redcraft.Utility/Source/Public/Templates/Templates.h +++ b/Redcraft.Utility/Source/Public/Templates/Templates.h @@ -15,6 +15,3 @@ #include "Templates/Function.h" #include "Templates/Atomic.h" #include "Templates/ScopeHelper.h" -#include "Templates/PointerTraits.h" -#include "Templates/UniquePointer.h" -#include "Templates/SharedPointer.h" diff --git a/Redcraft.Utility/Source/Public/Templates/Tuple.h b/Redcraft.Utility/Source/Public/Templates/Tuple.h index 4437d49..6f4b10e 100644 --- a/Redcraft.Utility/Source/Public/Templates/Tuple.h +++ b/Redcraft.Utility/Source/Public/Templates/Tuple.h @@ -6,6 +6,7 @@ #include "Templates/Utility.h" #include "Templates/TypeHash.h" #include "TypeTraits/TypeTraits.h" +#include "Miscellaneous/Compare.h" #include "Templates/ReferenceWrapper.h" #include diff --git a/Redcraft.Utility/Source/Public/Templates/Variant.h b/Redcraft.Utility/Source/Public/Templates/Variant.h index 945deb2..092fc3e 100644 --- a/Redcraft.Utility/Source/Public/Templates/Variant.h +++ b/Redcraft.Utility/Source/Public/Templates/Variant.h @@ -1,11 +1,11 @@ #pragma once #include "CoreTypes.h" +#include "Templates/Meta.h" #include "Templates/Invoke.h" #include "Templates/Utility.h" #include "Templates/TypeHash.h" #include "TypeTraits/TypeTraits.h" -#include "Templates/Meta.h" #include "Memory/MemoryOperator.h" #include "Miscellaneous/Compare.h" #include "Miscellaneous/AssertionMacros.h" diff --git a/Redcraft.Utility/Source/Public/Testing/MemoryTesting.h b/Redcraft.Utility/Source/Public/Testing/MemoryTesting.h index 4491fca..07c37b4 100644 --- a/Redcraft.Utility/Source/Public/Testing/MemoryTesting.h +++ b/Redcraft.Utility/Source/Public/Testing/MemoryTesting.h @@ -13,6 +13,9 @@ REDCRAFTUTILITY_API void TestAlignment(); REDCRAFTUTILITY_API void TestMemoryBuffer(); REDCRAFTUTILITY_API void TestMemoryMalloc(); REDCRAFTUTILITY_API void TestMemoryOperator(); +REDCRAFTUTILITY_API void TestPointerTraits(); +REDCRAFTUTILITY_API void TestUniquePointer(); +REDCRAFTUTILITY_API void TestSharedPointer(); NAMESPACE_END(Testing) diff --git a/Redcraft.Utility/Source/Public/Testing/TemplatesTesting.h b/Redcraft.Utility/Source/Public/Testing/TemplatesTesting.h index 5dc22b6..3d92d0f 100644 --- a/Redcraft.Utility/Source/Public/Testing/TemplatesTesting.h +++ b/Redcraft.Utility/Source/Public/Testing/TemplatesTesting.h @@ -18,8 +18,6 @@ REDCRAFTUTILITY_API void TestTuple(); REDCRAFTUTILITY_API void TestFunction(); REDCRAFTUTILITY_API void TestAtomic(); REDCRAFTUTILITY_API void TestScopeHelper(); -REDCRAFTUTILITY_API void TestUniquePointer(); -REDCRAFTUTILITY_API void TestSharedPointer(); REDCRAFTUTILITY_API void TestMiscTemplates(); NAMESPACE_END(Testing)