#include <slang/util/PoolAllocator.h>
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
-
template<typename TSubClass, typename... Args>auto emplace(Args && ... args) -> TSubClass*
- 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... Args>auto emplace(Args && ... args) -> T*
- 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 TSubClass>void destroy(TSubClass* elem)
- Destroys the given object and returns its memory to the pool to be reused by future allocations.