Allocator Builder
Policy Based C++ Template Allocator Library
 All Classes Functions Variables Enumerations Enumerator Groups Pages
alb::v_100::stack_allocator< MaxSize, Alignment > Class Template Reference

#include <stack_allocator.hpp>

Public Types

using allocator = stack_allocator
 

Public Member Functions

block allocate (size_t n) noexcept
 
void deallocate (block &b) noexcept
 
bool reallocate (block &b, size_t n) noexcept
 
bool expand (block &b, size_t delta) noexcept
 
bool owns (const block &b) const noexcept
 
void deallocate_all () noexcept
 

Static Public Attributes

static const bool supports_truncated_deallocation = true
 
static const size_t max_size = MaxSize
 
static const size_t alignment = Alignment
 

Detailed Description

template<size_t MaxSize, size_t Alignment = 16>
class alb::v_100::stack_allocator< MaxSize, Alignment >

Allocator that provides memory from the stack. By design it is not thread safe!

Template Parameters
MaxSizeThe maximum number of bytes that can be allocated by this allocator
AlignmentEach memory allocation request by allocate, reallocate and expand is aligned by this value

Definition at line 28 of file stack_allocator.hpp.

Member Function Documentation

template<size_t MaxSize, size_t Alignment = 16>
void alb::v_100::stack_allocator< MaxSize, Alignment >::deallocate_all ( )
inlinenoexcept

Sets all possibly provided memory to free. Be warned that all usage of previously allocated blocks results in unpredictable results!

Definition at line 169 of file stack_allocator.hpp.

template<size_t MaxSize, size_t Alignment = 16>
bool alb::v_100::stack_allocator< MaxSize, Alignment >::expand ( block b,
size_t  delta 
)
inlinenoexcept

Expands the given block insito by the amount of bytes

Parameters
bThe block that should be expanded
deltaThe amount of bytes that should be appended
Returns
true, if the operation was successful or false if not enough memory is left

Definition at line 135 of file stack_allocator.hpp.

template<size_t MaxSize, size_t Alignment = 16>
bool alb::v_100::stack_allocator< MaxSize, Alignment >::owns ( const block b) const
inlinenoexcept

Returns true, if the provided block was allocated previously with this allocator

Parameters
bThe block to be checked.

Definition at line 160 of file stack_allocator.hpp.


The documentation for this class was generated from the following file: