Thrill  0.1
StackArena< Size > Class Template Reference

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.

+ Collaboration diagram for StackArena< Size >:

#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 (const StackArena &)=delete
 
 ~StackArena ()
 destructor clears ptr_ for debugging. More...
 
char * allocate (size_t n)
 
void deallocate (char *p, size_t n) noexcept
 
StackArenaoperator= (const StackArena &)=delete
 
void reset () noexcept
 reset memory area More...
 
size_t used () const noexcept
 return number of bytes used in StackArena 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 = 16
 

Constructor & Destructor Documentation

◆ StackArena() [1/2]

StackArena ( )
inlinenoexcept

default constructor: free pointer at the beginning.

Definition at line 64 of file stack_allocator.hpp.

Referenced by StackArena< Size >::~StackArena().

◆ ~StackArena()

~StackArena ( )
inline

destructor clears ptr_ for debugging.

Definition at line 67 of file stack_allocator.hpp.

References StackArena< Size >::operator=(), and StackArena< Size >::StackArena().

◆ StackArena() [2/2]

StackArena ( const StackArena< Size > &  )
delete

Member Function Documentation

◆ allocate()

◆ deallocate()

void deallocate ( char *  p,
size_t  n 
)
inlinenoexcept

◆ operator=()

◆ pointer_in_buffer()

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.

References StackArena< Size >::buf_, and StackArena< Size >::AlignmentHelper::p.

Referenced by StackArena< Size >::allocate(), and StackArena< Size >::deallocate().

◆ reset()

void reset ( )
inlinenoexcept

reset memory area

Definition at line 110 of file stack_allocator.hpp.

References StackArena< Size >::buf_.

◆ size()

static constexpr size_t size ( )
inlinestaticnoexcept

size of memory area

Definition at line 104 of file stack_allocator.hpp.

◆ used()

size_t used ( ) const
inlinenoexcept

return number of bytes used in StackArena

Definition at line 107 of file stack_allocator.hpp.

References StackArena< Size >::buf_.

Member Data Documentation

◆ @23

union { ... }

◆ alignment

constexpr size_t alignment = 16
staticprivate

Definition at line 34 of file stack_allocator.hpp.

Referenced by StackArena< Size >::allocate().

◆ buf_

char buf_[Size]

stack memory area used for allocations.

Definition at line 50 of file stack_allocator.hpp.

Referenced by StackArena< Size >::allocate(), StackArena< Size >::pointer_in_buffer(), StackArena< Size >::reset(), and StackArena< Size >::used().

◆ dummy_for_alignment_

AlignmentHelper dummy_for_alignment_

enforce alignment

Definition at line 52 of file stack_allocator.hpp.

◆ ptr_

char* ptr_
private

pointer into free bytes in buf_

Definition at line 56 of file stack_allocator.hpp.

Referenced by StackArena< Size >::allocate().


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