KTL
ktl::stack_allocator< Size > Class Template Reference

A linear allocator which gives out chunks of its allocated stack. Increments a counter during allocation, which makes it very fast but also unlikely to deallocate it again. Has a max allocation size of the Size given. More...

#include <stack_allocator.h>

Public Member Functions

 stack_allocator (stack< Size > &block) noexcept
 
 stack_allocator (stack< Size > *block) noexcept
 
 stack_allocator (const stack_allocator &) noexcept=default
 
 stack_allocator (stack_allocator &&) noexcept=default
 
stack_allocatoroperator= (const stack_allocator &) noexcept=default
 
stack_allocatoroperator= (stack_allocator &&) noexcept=default
 
bool operator== (const stack_allocator &rhs) const noexcept
 
bool operator!= (const stack_allocator &rhs) const noexcept
 
void * allocate (size_t n) noexcept
 
void deallocate (void *p, size_t n) noexcept
 
size_t max_size () const noexcept
 
bool owns (void *p) const noexcept
 

Detailed Description

template<size_t Size>
class ktl::stack_allocator< Size >

A linear allocator which gives out chunks of its allocated stack. Increments a counter during allocation, which makes it very fast but also unlikely to deallocate it again. Has a max allocation size of the Size given.

Note
Cannot be default constructed because it needs a reference to a stack

Constructor & Destructor Documentation

◆ stack_allocator() [1/4]

template<size_t Size>
ktl::stack_allocator< Size >::stack_allocator ( stack< Size > &  block)
inlineexplicitnoexcept

◆ stack_allocator() [2/4]

template<size_t Size>
ktl::stack_allocator< Size >::stack_allocator ( stack< Size > *  block)
inlineexplicitnoexcept

◆ stack_allocator() [3/4]

template<size_t Size>
ktl::stack_allocator< Size >::stack_allocator ( const stack_allocator< Size > &  )
defaultnoexcept

◆ stack_allocator() [4/4]

template<size_t Size>
ktl::stack_allocator< Size >::stack_allocator ( stack_allocator< Size > &&  )
defaultnoexcept

Member Function Documentation

◆ allocate()

template<size_t Size>
void* ktl::stack_allocator< Size >::allocate ( size_t  n)
inlinenoexcept

◆ deallocate()

template<size_t Size>
void ktl::stack_allocator< Size >::deallocate ( void *  p,
size_t  n 
)
inlinenoexcept

◆ max_size()

template<size_t Size>
size_t ktl::stack_allocator< Size >::max_size ( ) const
inlinenoexcept

◆ operator!=()

template<size_t Size>
bool ktl::stack_allocator< Size >::operator!= ( const stack_allocator< Size > &  rhs) const
inlinenoexcept

◆ operator=() [1/2]

template<size_t Size>
stack_allocator& ktl::stack_allocator< Size >::operator= ( const stack_allocator< Size > &  )
defaultnoexcept

◆ operator=() [2/2]

template<size_t Size>
stack_allocator& ktl::stack_allocator< Size >::operator= ( stack_allocator< Size > &&  )
defaultnoexcept

◆ operator==()

template<size_t Size>
bool ktl::stack_allocator< Size >::operator== ( const stack_allocator< Size > &  rhs) const
inlinenoexcept

◆ owns()

template<size_t Size>
bool ktl::stack_allocator< Size >::owns ( void *  p) const
inlinenoexcept

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