diff --git a/Redcraft.Utility/Source/Private/Testing/MemoryTesting.cpp b/Redcraft.Utility/Source/Private/Testing/MemoryTesting.cpp index a11cee6..1c25135 100644 --- a/Redcraft.Utility/Source/Private/Testing/MemoryTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/MemoryTesting.cpp @@ -165,11 +165,11 @@ void TestMemoryOperator() FTracker* PtrB = reinterpret_cast(Memory::Malloc(sizeof(FTracker))); FTracker::Status = 0; - Memory::DefaultConstruct(PtrA); + Memory::DefaultConstruct(PtrA); always_check(FTracker::Status == -1); FTracker::Status = 1; - Memory::Construct(PtrA, PtrB); + Memory::Construct(PtrA, PtrB); always_check(FTracker::Status == -1); FTracker::Status = 1; diff --git a/Redcraft.Utility/Source/Public/Memory/MemoryOperator.h b/Redcraft.Utility/Source/Public/Memory/MemoryOperator.h index 6c9b325..a90f5de 100644 --- a/Redcraft.Utility/Source/Public/Memory/MemoryOperator.h +++ b/Redcraft.Utility/Source/Public/Memory/MemoryOperator.h @@ -13,15 +13,14 @@ NAMESPACE_BEGIN(Memory) template requires CDefaultConstructible -FORCEINLINE void DefaultConstruct(ElementType* Address, size_t Count = 1) +FORCEINLINE void DefaultConstruct(void* Address, size_t Count = 1) { if constexpr (!CTriviallyDefaultConstructible) { - ElementType* Element = Address; while (Count) { - new (Element) ElementType; - ++Element; + new (Address) ElementType; + ++reinterpret_cast(Address); --Count; } } @@ -29,7 +28,7 @@ FORCEINLINE void DefaultConstruct(ElementType* Address, size_t Count = 1) template requires CConstructibleFrom -FORCEINLINE void Construct(DestinationElementType* Destination, const SourceElementType* Source, size_t Count = 1) +FORCEINLINE void Construct(void* Destination, const SourceElementType* Source, size_t Count = 1) { if constexpr (CTriviallyConstructibleFrom && sizeof(DestinationElementType) == sizeof(SourceElementType)) { @@ -40,7 +39,7 @@ FORCEINLINE void Construct(DestinationElementType* Destination, const SourceElem while (Count) { new (Destination) DestinationElementType(*Source); - ++(DestinationElementType*&)Destination; + ++reinterpret_cast(Destination); ++Source; --Count; } @@ -49,7 +48,7 @@ FORCEINLINE void Construct(DestinationElementType* Destination, const SourceElem template requires CCopyConstructible -FORCEINLINE void CopyConstruct(ElementType* Destination, const ElementType* Source, size_t Count = 1) +FORCEINLINE void CopyConstruct(void* Destination, const ElementType* Source, size_t Count = 1) { if constexpr (CTriviallyCopyConstructible) { @@ -60,7 +59,7 @@ FORCEINLINE void CopyConstruct(ElementType* Destination, const ElementType* Sour while (Count) { new (Destination) ElementType(*Source); - ++(ElementType*&)Destination; + ++reinterpret_cast(Destination); ++Source; --Count; } @@ -69,7 +68,7 @@ FORCEINLINE void CopyConstruct(ElementType* Destination, const ElementType* Sour template requires CMoveConstructible -FORCEINLINE void MoveConstruct(ElementType* Destination, ElementType* Source, size_t Count = 1) +FORCEINLINE void MoveConstruct(void* Destination, ElementType* Source, size_t Count = 1) { if constexpr (CTriviallyMoveConstructible) { @@ -80,7 +79,7 @@ FORCEINLINE void MoveConstruct(ElementType* Destination, ElementType* Source, si while (Count) { new (Destination) ElementType(MoveTemp(*Source)); - ++(ElementType*&)Destination; + ++reinterpret_cast(Destination); ++Source; --Count; } @@ -120,7 +119,7 @@ FORCEINLINE void MoveAssign(ElementType* Destination, ElementType* Source, size_ while (Count) { *Destination = MoveTemp(*Source); - ++(ElementType*&)Destination; + ++Destination; ++Source; --Count; }