[+] AuNullHeapPointer<T>()

This commit is contained in:
Reece Wilson 2024-01-19 19:40:38 +00:00
parent 9fe0655959
commit 20e0473af1
2 changed files with 17 additions and 2 deletions

View File

@ -181,6 +181,7 @@ namespace Aurora::Memory
return AuSPtr<T>((T *)(pPtr + kAlignment), &Heap::DeleteThat<T>);
}
// note: callers can use AuHUPOf_t<T> pUniquePointer = AuNullHeapPointer<T>()
template <class T, class ...Args>
AuUPtr<T, decltype(&Heap::DeleteThat<T>)> NewClassUnique(Args &&...args)
@ -279,6 +280,8 @@ namespace Aurora::Memory
return AuSPtr<T>((T *)(pPtr + kAlignment), &Heap::DeleteThatArray<T>);
}
// note: callers can use AuHUPOf_t<T> pUniquePointer = AuNullHeapPointer<T>()
template <class T, class ...Args>
AuUPtr<T, decltype(&Heap::DeleteThat<T>)> NewClassArrayUnique(AuUInt uElements, Args &&... fillCtr)
{
@ -338,6 +341,12 @@ namespace Aurora::Memory
return AuUPtr<T, decltype(&Heap::DeleteThat<T>)>((T *)(pPtr + kAlignment), &Heap::DeleteThatArray<T>);
}
template <class T>
cstatic AuUPtr<T, decltype(&Heap::DeleteThat<T>)> NullUniquePointer()
{
return AuUPtr<T, decltype(&Heap::DeleteThat<T>)>(nullptr, &Heap::RetardedSpecWrittenByRetards<T>);
}
template<typename T>
static AuSPtr<T> ToSmartPointer(AuSPtr<Heap> heap,
T *pHead,
@ -412,4 +421,4 @@ namespace Aurora::Memory
// Proxies an existing heap with encapsulated statistics and leak detector
AUKN_SHARED_API(HeapProxyEx, Heap, const AuSPtr<Heap> &pHead, LeakFinderAlloc_f pfAlloc, LeakFinderFree_f pfFree);
}
}

View File

@ -116,4 +116,10 @@ static inline void AuDebugBreak()
}
template <typename T>
using AuHUPOf_t = typename Aurora::Memory::Heap::HUPOf_t<T>;
using AuHUPOf_t = typename Aurora::Memory::Heap::HUPOf_t<T>;
template <class T>
static inline auto AuNullHeapPointer()
{
return Aurora::Memory::Heap::NullUniquePointer<T>();
}