tlx
StackAllocator< Type, Size > Class Template Reference

#include <stack_allocator.hpp>

Inheritance diagram for StackAllocator< Type, Size >:
AllocatorBase< Type >

Classes

struct  rebind
 required rebind. More...
 

Public Types

using value_type = Type
 
using pointer = Type *
 
using const_pointer = const Type *
 
using reference = Type &
 
using const_reference = const Type &
 
using size_type = std::size_t
 
using difference_type = std::ptrdiff_t
 
using is_always_equal = std::false_type
 C++11 type flag. More...
 
- Public Types inherited from AllocatorBase< Type >
using value_type = Type
 
using pointer = Type *
 
using const_pointer = const Type *
 
using reference = Type &
 
using const_reference = const Type &
 
using size_type = std::size_t
 
using difference_type = std::ptrdiff_t
 
using is_always_equal = std::true_type
 C++11 type flag. More...
 
using propagate_on_container_move_assignment = std::true_type
 C++11 type flag. More...
 

Public Member Functions

 StackAllocator () noexcept
 default constructor to invalid arena More...
 
 StackAllocator (StackArena< Size > &arena) noexcept
 constructor with explicit arena reference More...
 
template<typename Other >
 StackAllocator (const StackAllocator< Other, Size > &other) noexcept
 constructor from another allocator with same arena size More...
 
 StackAllocator (const StackAllocator &) noexcept=default
 copy-constructor: default More...
 
StackAllocatoroperator= (const StackAllocator &) noexcept=default
 copy-assignment: default More...
 
 StackAllocator (StackAllocator &&) noexcept=default
 move-constructor: default More...
 
StackAllocatoroperator= (StackAllocator &&) noexcept=default
 move-assignment: default More...
 
pointer allocate (size_t n)
 allocate method: get memory from arena More...
 
void deallocate (pointer p, size_t n) noexcept
 deallocate method: release from arena More...
 
template<typename Other , size_t OtherSize>
bool operator== (const StackAllocator< Other, OtherSize > &other) const noexcept
 
template<typename Other , size_t OtherSize>
bool operator!= (const StackAllocator< Other, OtherSize > &other) const noexcept
 
- Public Member Functions inherited from AllocatorBase< Type >
pointer address (reference x) const noexcept
 Returns the address of x. More...
 
const_pointer address (const_reference x) const noexcept
 Returns the address of x. More...
 
size_type max_size () const noexcept
 Maximum size possible to allocate. More...
 
void construct (pointer p, const_reference value)
 Constructs an element object on the location pointed by p. More...
 
void destroy (pointer p) const noexcept
 Destroys in-place the object pointed by p. More...
 
template<typename SubType , typename... Args>
void construct (SubType *p, Args &&...args)
 Constructs an element object on the location pointed by p. More...
 
template<typename SubType >
void destroy (SubType *p) const noexcept
 Destroys in-place the object pointed by p. More...
 

Private Attributes

StackArena< Size > * arena_
 

Friends

template<typename Other , size_t OtherSize>
class StackAllocator
 

Detailed Description

template<typename Type, size_t Size>
class tlx::StackAllocator< Type, Size >

Definition at line 114 of file stack_allocator.hpp.

Member Typedef Documentation

using const_pointer = const Type *

Definition at line 119 of file stack_allocator.hpp.

using const_reference = const Type&

Definition at line 121 of file stack_allocator.hpp.

using difference_type = std::ptrdiff_t

Definition at line 123 of file stack_allocator.hpp.

using is_always_equal = std::false_type

C++11 type flag.

Definition at line 126 of file stack_allocator.hpp.

using pointer = Type *

Definition at line 118 of file stack_allocator.hpp.

using reference = Type&

Definition at line 120 of file stack_allocator.hpp.

using size_type = std::size_t

Definition at line 122 of file stack_allocator.hpp.

using value_type = Type

Definition at line 117 of file stack_allocator.hpp.

Constructor & Destructor Documentation

StackAllocator ( )
inlinenoexcept

default constructor to invalid arena

Definition at line 133 of file stack_allocator.hpp.

StackAllocator ( StackArena< Size > &  arena)
inlineexplicitnoexcept

constructor with explicit arena reference

Definition at line 136 of file stack_allocator.hpp.

StackAllocator ( const StackAllocator< Other, Size > &  other)
inlinenoexcept

constructor from another allocator with same arena size

Definition at line 141 of file stack_allocator.hpp.

StackAllocator ( const StackAllocator< Type, Size > &  )
defaultnoexcept

copy-constructor: default

StackAllocator ( StackAllocator< Type, Size > &&  )
defaultnoexcept

move-constructor: default

Member Function Documentation

pointer allocate ( size_t  n)
inline

allocate method: get memory from arena

Definition at line 159 of file stack_allocator.hpp.

void deallocate ( pointer  p,
size_t  n 
)
inlinenoexcept

deallocate method: release from arena

Definition at line 164 of file stack_allocator.hpp.

bool operator!= ( const StackAllocator< Other, OtherSize > &  other) const
inlinenoexcept

Definition at line 175 of file stack_allocator.hpp.

StackAllocator& operator= ( const StackAllocator< Type, Size > &  )
defaultnoexcept

copy-assignment: default

StackAllocator& operator= ( StackAllocator< Type, Size > &&  )
defaultnoexcept

move-assignment: default

bool operator== ( const StackAllocator< Other, OtherSize > &  other) const
inlinenoexcept

Definition at line 169 of file stack_allocator.hpp.

Friends And Related Function Documentation

friend class StackAllocator
friend

Definition at line 181 of file stack_allocator.hpp.

Member Data Documentation

StackArena<Size>* arena_
private

Definition at line 184 of file stack_allocator.hpp.


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