tlx
Loading...
Searching...
No Matches
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.
 ~StackArena ()
 destructor clears ptr_ for debugging.
 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
void reset () noexcept
 reset memory area

Static Public Member Functions

static constexpr size_t size () noexcept
 size of memory area

Private Member Functions

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

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_

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() [1/2]

template<size_t Size>
StackArena ( )
inlinenoexcept

default constructor: free pointer at the beginning.

Definition at line 64 of file stack_allocator.hpp.

◆ ~StackArena()

template<size_t Size>
~StackArena ( )
inline

destructor clears ptr_ for debugging.

Definition at line 67 of file stack_allocator.hpp.

◆ StackArena() [2/2]

template<size_t Size>
StackArena ( const StackArena< Size > & )
delete

Member Function Documentation

◆ allocate()

template<size_t Size>
char * allocate ( size_t n)
inline

Definition at line 72 of file stack_allocator.hpp.

◆ deallocate()

template<size_t Size>
void deallocate ( char * p,
size_t n )
inlinenoexcept

Definition at line 88 of file stack_allocator.hpp.

◆ operator=()

template<size_t Size>
StackArena & operator= ( const StackArena< Size > & )
delete

◆ pointer_in_buffer()

template<size_t Size>
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.

◆ reset()

template<size_t Size>
void reset ( )
inlinenoexcept

reset memory area

Definition at line 110 of file stack_allocator.hpp.

◆ size()

template<size_t Size>
constexpr size_t size ( )
inlinestaticconstexprnoexcept

size of memory area

Definition at line 104 of file stack_allocator.hpp.

◆ used()

template<size_t Size>
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]

union { ... }

◆ alignment

template<size_t Size>
size_t alignment
staticconstexprprivate

Definition at line 34 of file stack_allocator.hpp.

◆ buf_

template<size_t Size>
char buf_[Size]

stack memory area used for allocations.

Definition at line 50 of file stack_allocator.hpp.

◆ dummy_for_alignment_

template<size_t Size>
AlignmentHelper dummy_for_alignment_

enforce alignment

Definition at line 52 of file stack_allocator.hpp.

◆ ptr_

template<size_t Size>
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: