diff --git a/Include/Aurora/Memory/Heap.hpp b/Include/Aurora/Memory/Heap.hpp index f34e9b7e..5145a1bc 100644 --- a/Include/Aurora/Memory/Heap.hpp +++ b/Include/Aurora/Memory/Heap.hpp @@ -98,11 +98,8 @@ namespace Aurora::Memory { static const auto kAlignment = AuMax(alignof(T), sizeof(void *)); - if constexpr (AuIsClass_v - #if !defined(AURT_HEAP_NO_STL) - && !std::is_trivially_destructible_v - #endif - ) + if constexpr (AuIsClass_v && + !AuIsTriviallyDefaultConstructible_v) { pThat->~T(); } @@ -120,11 +117,8 @@ namespace Aurora::Memory auto pHeap = (Heap *)pVoids[0]; auto uCount = (AuUInt)pVoids[1]; - if constexpr (AuIsClass_v - #if !defined(AURT_HEAP_NO_STL) - && !std::is_trivially_destructible_v - #endif - ) + if constexpr (AuIsClass_v && + !AuIsTriviallyDefaultConstructible_v) { for (AU_ITERATE_N(i, uCount)) { @@ -139,15 +133,12 @@ namespace Aurora::Memory template static void DeleteThatCastedOnce(T *pThat) { - static const auto kAlignment = AuMax(alignof(T), sizeof(void *)); + static const auto kAlignment = AuMax(alignof(Z), sizeof(void *)); auto pBaseClass = AuStaticCast(pThat); - if constexpr (AuIsClass_v - #if !defined(AURT_HEAP_NO_STL) - && !std::is_trivially_destructible_v - #endif - ) + if constexpr (AuIsClass_v && + !AuIsTriviallyDefaultConstructible_v) { pBaseClass->~Z(); } @@ -176,11 +167,8 @@ namespace Aurora::Memory pThat = this; } - if constexpr (AuIsClass_v - #if !defined(AURT_HEAP_NO_STL) - && !std::is_trivially_constructible_v - #endif - ) + if constexpr (AuIsClass_v && + !AuIsTriviallyDefaultConstructible_v) { pPtr = pThat->FAlloc(sizeof(T) + kAlignment, kAlignment); if (pPtr) @@ -204,8 +192,8 @@ namespace Aurora::Memory // note: callers can use AuHUPOf_t pUniquePointer = AuNullHeapPointer() - template - AuUPtr)> NewClassUnique(Args &&...args) + template + AuUPtr)> NewClassUnique(Args &&...args) { static const auto kAlignment = AuMax(alignof(T), sizeof(void *)); AuUInt8 *pPtr; @@ -216,11 +204,8 @@ namespace Aurora::Memory pThat = this; } - if constexpr (AuIsClass_v - #if !defined(AURT_HEAP_NO_STL) - && !std::is_trivially_constructible_v - #endif - ) + if constexpr (AuIsClass_v && + !AuIsTriviallyDefaultConstructible_v) { pPtr = pThat->FAlloc(sizeof(T) + kAlignment, kAlignment); if (pPtr) @@ -235,11 +220,19 @@ namespace Aurora::Memory if (!pPtr) { - return AuUPtr)>(nullptr, &Heap::RetardedSpecWrittenByRetards); + return AuUPtr)>(nullptr, &Heap::RetardedSpecWrittenByRetards); } *(void **)pPtr = pThat; - return AuUPtr)>((T *)(pPtr + kAlignment), &Heap::DeleteThat); + + if constexpr (AuIsSame_v) + { + return AuUPtr)>((T *)(pPtr + kAlignment), &Heap::DeleteThat); + } + else + { + return Heap::CastPointer(AuMove(AuUPtr)>((T *)(pPtr + kAlignment), &Heap::DeleteThat))); + } } template @@ -259,11 +252,8 @@ namespace Aurora::Memory pThat = this; } - if constexpr (AuIsClass_v - #if !defined(AURT_HEAP_NO_STL) - && !std::is_trivially_constructible_v - #endif - ) + if constexpr (AuIsClass_v && + !AuIsTriviallyDefaultConstructible_v) { if (bool(pPtr = pThat->FAlloc((sizeof(T) * uElements) + kAlignment, kAlignment))) { @@ -320,11 +310,8 @@ namespace Aurora::Memory pThat = this; } - if constexpr (AuIsClass_v - #if !defined(AURT_HEAP_NO_STL) - && !std::is_trivially_constructible_v - #endif - ) + if constexpr (AuIsClass_v && + !AuIsTriviallyDefaultConstructible_v) { if (bool(pPtr = pThat->FAlloc((sizeof(T) * uElements) + kAlignment, kAlignment))) {