[*] fuck the brain diseased demented boomers on the c++ arse sniffing committee

This commit is contained in:
Reece Wilson 2024-01-30 08:55:08 +00:00
parent 62b6fa20f8
commit b7a5bfe8b3

View File

@ -48,14 +48,22 @@ namespace Aurora::Memory
pHeap(pHeap)
{ }
AU_COPY_MOVE_DEF(CppHeapWrapper)
std::shared_ptr<Heap> pHeap;
inline CppHeapWrapper(CppHeapWrapper *pFuckCppRetardsFixYourWorthlessSpec) :
pFuckCppRetardsFixYourWorthlessSpec(pFuckCppRetardsFixYourWorthlessSpec)
{ }
inline CppHeapWrapper(const CppHeapWrapper &fuckCpp) :
pFuckCppRetardsFixYourWorthlessSpec((CppHeapWrapper *)&fuckCpp)
{ }
AU_MOVE(CppHeapWrapper)
AU_DEF(CppHeapWrapper)
constexpr void deallocate(const T *pType,
const size_t count)
{
this->pHeap->Free((T *)pType);
this->GetHeap()->Free((T *)pType);
}
constexpr AU_ALLOC T *allocate(const size_t count)
@ -65,7 +73,7 @@ namespace Aurora::Memory
return nullptr;
}
auto pData = this->pHeap->FAlloc(count, alignof(T));
auto pData = this->GetHeap()->FAlloc(count * sizeof(T), alignof(T));
if (!pData)
{
throw std::bad_alloc();
@ -73,12 +81,58 @@ namespace Aurora::Memory
return (T *)pData;
}
template <class U, class... Args >
void construct(U *p, Args&&... args)
{
if constexpr (AuIsClass_v<T>)
{
new ((void *)p) T(AuForward<Args &&>(args)...);
}
}
template <class U, class... Args >
void construct_at(U *p, Args&&... args)
{
if constexpr (AuIsClass_v<T>)
{
new ((void *)p) T(AuForward<Args &&>(args)...);
}
}
#if defined(AU_LANG_CPP_23)
constexpr std::allocation_result<T *> allocate_at_least(const size_t count)
{
auto pThat = this->allocate(count);
return { pThat, this->pHeap->GetChunkSize(pThat) };
return { (T *)pThat, this->GetHeap()->GetChunkSize(pThat) / sizeof(T) };
}
#endif
std::shared_ptr<Heap> &GetHeap()
{
if (this->pFuckCppRetardsFixYourWorthlessSpec)
{
return this->pFuckCppRetardsFixYourWorthlessSpec->GetHeap();
}
else
{
return this->pHeap;
}
}
void SetHeap(std::shared_ptr<Heap> pHeap)
{
if (this->pFuckCppRetardsFixYourWorthlessSpec)
{
this->pFuckCppRetardsFixYourWorthlessSpec->SetHeap(pHeap);
}
else
{
this->pHeap = pHeap;
}
}
private:
std::shared_ptr<Heap> pHeap;
CppHeapWrapper *pFuckCppRetardsFixYourWorthlessSpec {};
};
}