[*] Nuke some std:: usage under AuMemory::Heap

This commit is contained in:
Reece Wilson 2024-03-17 13:16:43 +00:00
parent 07889bfb3e
commit a7033c40e2

View File

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