[+] AuCastPointer because C++ is a big pile of shit (TODO: port to AuROXTL)
This commit is contained in:
parent
f049053776
commit
3dc82bf1cb
@ -347,6 +347,20 @@ namespace Aurora::Memory
|
||||
return AuUPtr<T, decltype(&Heap::DeleteThat<T>)>(nullptr, &Heap::RetardedSpecWrittenByRetards<T>);
|
||||
}
|
||||
|
||||
template <class Z, class T>
|
||||
cstatic AuUPtr<Z, decltype(&Heap::DeleteThat<Z>)> CastPointer(AuUPtr<T, decltype(&Heap::DeleteThat<T>)> &&pInPointer)
|
||||
{
|
||||
if (!pInPointer)
|
||||
{
|
||||
return NullUniquePointer<Z>();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto deleter = decltype(&Heap::DeleteThat<Z>)(pInPointer.get_deleter());
|
||||
return AuUPtr<Z, decltype(&Heap::DeleteThat<Z>)>(AuStaticCast<Z>(pInPointer.release()), deleter);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static AuSPtr<T> ToSmartPointer(AuSPtr<Heap> heap,
|
||||
T *pHead,
|
||||
|
@ -154,4 +154,58 @@ template <class T, class ...Args>
|
||||
AuSPtr<T> AuNewClass(Args &&...args)
|
||||
{
|
||||
return Aurora::Memory::GetDefaultDiscontiguousHeap()->NewClass<T, Args...>(AuForward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <class T, class ...Args>
|
||||
AuHUPOf_t<T> AuNewClassArrayUnique(Aurora::Memory::Heap *pHeap, AuUInt uElements, Args &&... fillCtr)
|
||||
{
|
||||
return pHeap->NewClassArrayUnique<T, Args...>(uElements, AuForward<Args>(fillCtr)...);
|
||||
}
|
||||
|
||||
template <class T, class ...Args>
|
||||
AuSPtr<T> AuNewClassArray(Aurora::Memory::Heap *pHeap, AuUInt uElements, Args &&... fillCtr)
|
||||
{
|
||||
return pHeap->NewClassArray<T, Args...>(uElements, AuForward<Args>(fillCtr)...);
|
||||
}
|
||||
|
||||
template <class T, class ...Args>
|
||||
AuHUPOf_t<T> AuNewClassUnique(Aurora::Memory::Heap *pHeap, Args &&...args)
|
||||
{
|
||||
return pHeap->NewClassUnique<T, Args...>(AuForward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <class T, class ...Args>
|
||||
AuSPtr<T> AuNewClass(Aurora::Memory::Heap *pHeap, Args &&...args)
|
||||
{
|
||||
return pHeap->NewClass<T, Args...>(AuForward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <class T, class ...Args>
|
||||
AuHUPOf_t<T> AuNewClassArrayUnique(const AuSPtr<Aurora::Memory::Heap> &pHeap, AuUInt uElements, Args &&... fillCtr)
|
||||
{
|
||||
return pHeap->NewClassArrayUnique<T, Args...>(uElements, AuForward<Args>(fillCtr)...);
|
||||
}
|
||||
|
||||
template <class T, class ...Args>
|
||||
AuSPtr<T> AuNewClassArray(const AuSPtr<Aurora::Memory::Heap> &pHeap, AuUInt uElements, Args &&... fillCtr)
|
||||
{
|
||||
return pHeap->NewClassArray<T, Args...>(uElements, AuForward<Args>(fillCtr)...);
|
||||
}
|
||||
|
||||
template <class T, class ...Args>
|
||||
AuHUPOf_t<T> AuNewClassUnique(const AuSPtr<Aurora::Memory::Heap> &pHeap, Args &&...args)
|
||||
{
|
||||
return pHeap->NewClassUnique<T, Args...>(AuForward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <class T, class ...Args>
|
||||
AuSPtr<T> AuNewClass(const AuSPtr<Aurora::Memory::Heap> &pHeap, Args &&...args)
|
||||
{
|
||||
return pHeap->NewClass<T, Args...>(AuForward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <class Z, class T>
|
||||
AuHUPOf_t<Z> AuCastPointer(AuHUPOf_t<T> &&pInPointer)
|
||||
{
|
||||
return Aurora::Memory::Heap::CastPointer<Z>(AuMove(pInPointer));
|
||||
}
|
Loading…
Reference in New Issue
Block a user