tlx
StackArena< Size > Class Template Reference

Storage area allocated on the stack and usable by a StackAllocator. More...

#include <stack_allocator.hpp>

Classes

union  AlignmentHelper
 union to enforce alignment of buffer area More...
 

Public Member Functions

 StackArena () noexcept
 default constructor: free pointer at the beginning. More...
 
 ~StackArena ()
 destructor clears ptr_ for debugging. More...
 
 StackArena (const StackArena &)=delete
 
StackArenaoperator= (const StackArena &)=delete
 
char * allocate (size_t n)
 
void deallocate (char *p, size_t n) noexcept
 
size_t used () const noexcept
 return number of bytes used in StackArena More...
 
void reset () noexcept
 reset memory area More...
 

Static Public Member Functions

static constexpr size_t size () noexcept
 size of memory area More...
 

Private Member Functions

bool pointer_in_buffer (char *p) noexcept
 debug method to check whether ptr_ is still in buf_. More...
 

Private Attributes

union {
   char   buf_ [Size]
 stack memory area used for allocations. More...
 
   AlignmentHelper   dummy_for_alignment_
 enforce alignment More...
 
}; 
 
char * ptr_
 pointer into free bytes in buf_ More...
 

Static Private Attributes

static constexpr size_t alignment
 

Detailed Description

template<size_t Size>
class tlx::StackArena< Size >

Storage area allocated on the stack and usable by a StackAllocator.

Definition at line 32 of file stack_allocator.hpp.

Constructor & Destructor Documentation

StackArena ( )
inlinenoexcept

default constructor: free pointer at the beginning.

Definition at line 64 of file stack_allocator.hpp.

~StackArena ( )
inline

destructor clears ptr_ for debugging.

Definition at line 67 of file stack_allocator.hpp.

StackArena ( const StackArena< Size > &  )
delete

Member Function Documentation

char* allocate ( size_t  n)
inline

Definition at line 72 of file stack_allocator.hpp.

void deallocate ( char *  p,
size_t  n 
)
inlinenoexcept

Definition at line 88 of file stack_allocator.hpp.

StackArena& operator= ( const StackArena< Size > &  )
delete
bool pointer_in_buffer ( char *  p)
inlineprivatenoexcept

debug method to check whether ptr_ is still in buf_.

Definition at line 59 of file stack_allocator.hpp.

void reset ( )
inlinenoexcept

reset memory area

Definition at line 110 of file stack_allocator.hpp.

static constexpr size_t size ( )
inlinestaticnoexcept

size of memory area

Definition at line 104 of file stack_allocator.hpp.

size_t used ( ) const
inlinenoexcept

return number of bytes used in StackArena

Definition at line 107 of file stack_allocator.hpp.

Member Data Documentation

union { ... }
constexpr size_t alignment
staticprivate

Definition at line 34 of file stack_allocator.hpp.

char buf_[Size]

stack memory area used for allocations.

Definition at line 50 of file stack_allocator.hpp.

AlignmentHelper dummy_for_alignment_

enforce alignment

Definition at line 52 of file stack_allocator.hpp.

char* ptr_
private

pointer into free bytes in buf_

Definition at line 56 of file stack_allocator.hpp.


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