[+] AuHeapUniqueDeleterClass

This commit is contained in:
Reece Wilson 2024-09-22 17:14:56 +01:00
parent 21f35e0bea
commit c3a1ae1576
4 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,26 @@
/***
Copyright (C) 2024 Jamie Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuHeapUniqueDeleterClass.hpp
Date: 2024-09-22
Author: Reece
***/
#pragma once
template <typename Type, typename Expects = Type>
struct AuHeapUniqueDeleterClass : AuHeapAccessor2
{
inline static auto Get()
{
return AuHeapAccessor2::Get<Type>();
}
inline void operator()(Expects *pThat) const
{
if (!pThat)
{
return;
}
Get()((Type *)pThat);
}
};

View File

@ -141,6 +141,7 @@ public:
protected:
friend struct AuHeapAccessor;
friend struct AuHeapAccessor2;
friend struct Aurora::Memory::ProxyHeap;
virtual AuSPtr<AuHeap> GetSelfReference() = 0; // may return empty/default. not all heaps are sharable.
@ -155,4 +156,4 @@ protected:
virtual AU_ALLOC void *_FRealloc(void *pBase, AuUInt uLength, AuUInt uAlign) = 0;
virtual AU_ALLOC void *_FRealloc(void *pBase, AuUInt uLength) = 0;
virtual void _Free(void* pBase) = 0;
};
};

View File

@ -21,3 +21,13 @@ struct AuHeapAccessor
return pHeap->GetSelfReferenceRaw();
}
};
struct AuHeapAccessor2
{
protected:
template <typename Type>
inline static auto Get()
{
return &AuHeap::DeleteThat<Type>;
}
};

View File

@ -459,6 +459,7 @@ inline constexpr bool operator!=(const Aurora::Memory::BaseAuroraRuntimeAllocato
#include <auROXTL/MemoryModel/auHeapStats.hpp>
#include <auROXTL/MemoryModel/auHeap.hpp>
#include <auROXTL/MemoryModel/auHeapAccessor.hpp>
#include <auROXTL/MemoryModel/AuHeapUniqueDeleterClass.hpp>
#include <auROXTL/MemoryModel/auDummyHeap.hpp>