slang::BumpAllocator class

Contents

BumpAllocator - Fast O(1) allocator.

Allocates items sequentially in memory, with underlying memory allocated in blocks as needed. Individual items cannot be deallocated; the entire thing must be destroyed to release the memory.

Derived classes

class Compilation
template<typename T>
class TypedBumpAllocator
template<typename T>
class TypedBumpAllocator
template<typename T>
class TypedBumpAllocator
template<typename T>
class TypedBumpAllocator
template<typename T>
class TypedBumpAllocator
template<typename T>
class TypedBumpAllocator

Public functions

template<typename T, typename... Args>
auto emplace(Args && ... args) -> T*
auto allocate(size_t size, size_t alignment) -> byte*
Allocate size bytes of memory with the given alignment.
void steal(BumpAllocator&& other)

Function documentation

template<typename T, typename... Args>
T* slang::BumpAllocator::emplace(Args && ... args)

Construct a new item using the allocator. NOTE: the type of object being created must be trivially destructible, since the allocator won't run destructors when freeing memory.

void slang::BumpAllocator::steal(BumpAllocator&& other)

Steals ownership of all of the memory contents of the given allocator. The other allocator will be in a moved-from state after the call.