[*] Nuke some std:: usage under AuMemory::Heap
This commit is contained in:
parent
07889bfb3e
commit
a7033c40e2
@ -98,11 +98,8 @@ namespace Aurora::Memory
|
|||||||
{
|
{
|
||||||
static const auto kAlignment = AuMax(alignof(T), sizeof(void *));
|
static const auto kAlignment = AuMax(alignof(T), sizeof(void *));
|
||||||
|
|
||||||
if constexpr (AuIsClass_v<T>
|
if constexpr (AuIsClass_v<T> &&
|
||||||
#if !defined(AURT_HEAP_NO_STL)
|
!AuIsTriviallyDefaultConstructible_v<T>)
|
||||||
&& !std::is_trivially_destructible_v<T>
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
pThat->~T();
|
pThat->~T();
|
||||||
}
|
}
|
||||||
@ -120,11 +117,8 @@ namespace Aurora::Memory
|
|||||||
auto pHeap = (Heap *)pVoids[0];
|
auto pHeap = (Heap *)pVoids[0];
|
||||||
auto uCount = (AuUInt)pVoids[1];
|
auto uCount = (AuUInt)pVoids[1];
|
||||||
|
|
||||||
if constexpr (AuIsClass_v<T>
|
if constexpr (AuIsClass_v<T> &&
|
||||||
#if !defined(AURT_HEAP_NO_STL)
|
!AuIsTriviallyDefaultConstructible_v<T>)
|
||||||
&& !std::is_trivially_destructible_v<T>
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
for (AU_ITERATE_N(i, uCount))
|
for (AU_ITERATE_N(i, uCount))
|
||||||
{
|
{
|
||||||
@ -139,15 +133,12 @@ namespace Aurora::Memory
|
|||||||
template <typename T, typename Z>
|
template <typename T, typename Z>
|
||||||
static void DeleteThatCastedOnce(T *pThat)
|
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);
|
auto pBaseClass = AuStaticCast<Z>(pThat);
|
||||||
|
|
||||||
if constexpr (AuIsClass_v<Z>
|
if constexpr (AuIsClass_v<Z> &&
|
||||||
#if !defined(AURT_HEAP_NO_STL)
|
!AuIsTriviallyDefaultConstructible_v<Z>)
|
||||||
&& !std::is_trivially_destructible_v<Z>
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
pBaseClass->~Z();
|
pBaseClass->~Z();
|
||||||
}
|
}
|
||||||
@ -176,11 +167,8 @@ namespace Aurora::Memory
|
|||||||
pThat = this;
|
pThat = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if constexpr (AuIsClass_v<T>
|
if constexpr (AuIsClass_v<T> &&
|
||||||
#if !defined(AURT_HEAP_NO_STL)
|
!AuIsTriviallyDefaultConstructible_v<T>)
|
||||||
&& !std::is_trivially_constructible_v<T>
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
pPtr = pThat->FAlloc<AuUInt8 *>(sizeof(T) + kAlignment, kAlignment);
|
pPtr = pThat->FAlloc<AuUInt8 *>(sizeof(T) + kAlignment, kAlignment);
|
||||||
if (pPtr)
|
if (pPtr)
|
||||||
@ -204,8 +192,8 @@ namespace Aurora::Memory
|
|||||||
|
|
||||||
// note: callers can use AuHUPOf_t<T> pUniquePointer = AuNullHeapPointer<T>()
|
// note: callers can use AuHUPOf_t<T> pUniquePointer = AuNullHeapPointer<T>()
|
||||||
|
|
||||||
template <class T, class ...Args>
|
template <class T, class Z = T, class ...Args>
|
||||||
AuUPtr<T, decltype(&Heap::DeleteThat<T>)> NewClassUnique(Args &&...args)
|
AuUPtr<Z, decltype(&Heap::DeleteThat<Z>)> NewClassUnique(Args &&...args)
|
||||||
{
|
{
|
||||||
static const auto kAlignment = AuMax(alignof(T), sizeof(void *));
|
static const auto kAlignment = AuMax(alignof(T), sizeof(void *));
|
||||||
AuUInt8 *pPtr;
|
AuUInt8 *pPtr;
|
||||||
@ -216,11 +204,8 @@ namespace Aurora::Memory
|
|||||||
pThat = this;
|
pThat = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if constexpr (AuIsClass_v<T>
|
if constexpr (AuIsClass_v<T> &&
|
||||||
#if !defined(AURT_HEAP_NO_STL)
|
!AuIsTriviallyDefaultConstructible_v<T>)
|
||||||
&& !std::is_trivially_constructible_v<T>
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
pPtr = pThat->FAlloc<AuUInt8 *>(sizeof(T) + kAlignment, kAlignment);
|
pPtr = pThat->FAlloc<AuUInt8 *>(sizeof(T) + kAlignment, kAlignment);
|
||||||
if (pPtr)
|
if (pPtr)
|
||||||
@ -235,11 +220,19 @@ namespace Aurora::Memory
|
|||||||
|
|
||||||
if (!pPtr)
|
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;
|
*(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>
|
template <class T, class ...Args>
|
||||||
@ -259,11 +252,8 @@ namespace Aurora::Memory
|
|||||||
pThat = this;
|
pThat = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if constexpr (AuIsClass_v<T>
|
if constexpr (AuIsClass_v<T> &&
|
||||||
#if !defined(AURT_HEAP_NO_STL)
|
!AuIsTriviallyDefaultConstructible_v<T>)
|
||||||
&& !std::is_trivially_constructible_v<T>
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (bool(pPtr = pThat->FAlloc<AuUInt8 *>((sizeof(T) * uElements) + kAlignment, kAlignment)))
|
if (bool(pPtr = pThat->FAlloc<AuUInt8 *>((sizeof(T) * uElements) + kAlignment, kAlignment)))
|
||||||
{
|
{
|
||||||
@ -320,11 +310,8 @@ namespace Aurora::Memory
|
|||||||
pThat = this;
|
pThat = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if constexpr (AuIsClass_v<T>
|
if constexpr (AuIsClass_v<T> &&
|
||||||
#if !defined(AURT_HEAP_NO_STL)
|
!AuIsTriviallyDefaultConstructible_v<T>)
|
||||||
&& !std::is_trivially_constructible_v<T>
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (bool(pPtr = pThat->FAlloc<AuUInt8 *>((sizeof(T) * uElements) + kAlignment, kAlignment)))
|
if (bool(pPtr = pThat->FAlloc<AuUInt8 *>((sizeof(T) * uElements) + kAlignment, kAlignment)))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user