#include <slang/util/PoolAllocator.h>
template<typename T, size_t Size = sizeof(T), size_t Align = alignof(T)>
PoolAllocator class
A simple pool allocator built on top of a bump allocator.
The pool contains objects of type T, or objects of some type derived from type T.
Constructors, destructors, conversion operators
- PoolAllocator(BumpAllocator& alloc) explicit
- Constructs a new instance of PoolAllocator.
Public functions
Function documentation
template<typename T, size_t Size, size_t Align>
template<typename TSubClass, typename... Args>
TSubClass* slang:: PoolAllocator<T, Size, Align>:: emplace(Args && ... args)
Allocates and constructs a new object of type TSubClass, reusing pooled memory if any is available and requesting more from the underlying BumpAllocator if not.
template<typename T, size_t Size, size_t Align>
template<typename... Args>
T* slang:: PoolAllocator<T, Size, Align>:: emplace(Args && ... args)
Allocates and constructs a new object of type T, reusing pooled memory if any is available and requesting more from the underlying BumpAllocator if not.
template<typename T, size_t Size, size_t Align>
template<typename TSubClass>
void slang:: PoolAllocator<T, Size, Align>:: destroy(TSubClass* elem)
Destroys the given object and returns its memory to the pool to be reused by future allocations.