mn::memory::basic_allocator< TAllocator, TFilter > Class Template Reference

#include <mn_basic_allocator.hpp>

+ Collaboration diagram for mn::memory::basic_allocator< TAllocator, TFilter >:

Public Types

using allocator_category = typename TAllocator::allocator_category
 
using is_thread_safe = typename TAllocator::is_thread_safe
 
using filter_type = TFilter
 
using value_type = void
 
using pointer = void *
 
using const_pointer = const void *
 
using difference_type = mn::ptrdiff_t
 
using size_type = size_t
 

Public Member Functions

 basic_allocator () noexcept
 
pointer allocate (size_t size, size_t alignment)
 malloc() a buffer in a given TAllocator and cheak with the given TFilter is this okay to alloc More...
 
pointer allocate (size_t size)
 malloc() a buffer in a given TAllocator and cheak with the given TFilter is this okay to alloc More...
 
pointer allocate (size_t count, size_t size, size_t alignment=0)
 malloc() a buffer in a given TAllocator and cheak with the given TFilter is this okay to alloc More...
 
void deallocate (pointer address, size_t size, size_t alignment) noexcept
 free() a buffer in a given heap. More...
 
void deallocate (pointer address, size_t size) noexcept
 free() a buffer in a given heap. More...
 
void deallocate (pointer address, size_t count, size_t size, size_t alignment) noexcept
 free() a buffer in a given heap. More...
 
template<class Type , typename... Args>
Type * construct (Args &&... args)
 Construct a object from allocated impl. More...
 
template<class Type >
void destroy (Type *address) noexcept
 Deconstruct a object (call deconstructor) and free the memory. More...
 
size_t get_max_alocator_size () const noexcept
 Get the maximal size to allocate. More...
 

Private Attributes

filter_type m_fFilter
 

Detailed Description

template<class TAllocator, class TFilter = basic_allocator_filter>
class mn::memory::basic_allocator< TAllocator, TFilter >

The basic allocater for all allocator impl in this library.

Member Typedef Documentation

◆ allocator_category

template<class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_allocator< TAllocator, TFilter >::allocator_category = typename TAllocator::allocator_category

◆ const_pointer

template<class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_allocator< TAllocator, TFilter >::const_pointer = const void*

◆ difference_type

template<class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_allocator< TAllocator, TFilter >::difference_type = mn::ptrdiff_t

◆ filter_type

template<class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_allocator< TAllocator, TFilter >::filter_type = TFilter

◆ is_thread_safe

template<class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_allocator< TAllocator, TFilter >::is_thread_safe = typename TAllocator::is_thread_safe

◆ pointer

template<class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_allocator< TAllocator, TFilter >::pointer = void*

◆ size_type

template<class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_allocator< TAllocator, TFilter >::size_type = size_t

◆ value_type

template<class TAllocator , class TFilter = basic_allocator_filter>
using mn::memory::basic_allocator< TAllocator, TFilter >::value_type = void

Constructor & Destructor Documentation

◆ basic_allocator()

template<class TAllocator , class TFilter = basic_allocator_filter>
mn::memory::basic_allocator< TAllocator, TFilter >::basic_allocator ( )
inlinenoexcept

Member Function Documentation

◆ allocate() [1/3]

template<class TAllocator , class TFilter = basic_allocator_filter>
pointer mn::memory::basic_allocator< TAllocator, TFilter >::allocate ( size_t  count,
size_t  size,
size_t  alignment = 0 
)
inline

malloc() a buffer in a given TAllocator and cheak with the given TFilter is this okay to alloc

Parameters
sizeThe size of the Type
countThe count of the array
alignment
Returns
Pointer to new memory, or NULL if allocation fails.

◆ allocate() [2/3]

template<class TAllocator , class TFilter = basic_allocator_filter>
pointer mn::memory::basic_allocator< TAllocator, TFilter >::allocate ( size_t  size)
inline

malloc() a buffer in a given TAllocator and cheak with the given TFilter is this okay to alloc

Parameters
sizeSize of desired buffer.
Returns
Pointer to new memory, or NULL if allocation fails.

◆ allocate() [3/3]

template<class TAllocator , class TFilter = basic_allocator_filter>
pointer mn::memory::basic_allocator< TAllocator, TFilter >::allocate ( size_t  size,
size_t  alignment 
)
inline

malloc() a buffer in a given TAllocator and cheak with the given TFilter is this okay to alloc

Parameters
sizeSize of desired buffer.
alignment
Returns
Pointer to new memory, or NULL if allocation fails.

◆ construct()

template<class TAllocator , class TFilter = basic_allocator_filter>
template<class Type , typename... Args>
Type* mn::memory::basic_allocator< TAllocator, TFilter >::construct ( Args &&...  args)
inline

Construct a object from allocated impl.

Template Parameters
TypeThe type of the object.
Parameters
ArgsThe arguments for the constructer of the object.

◆ deallocate() [1/3]

template<class TAllocator , class TFilter = basic_allocator_filter>
void mn::memory::basic_allocator< TAllocator, TFilter >::deallocate ( pointer  address,
size_t  count,
size_t  size,
size_t  alignment 
)
inlinenoexcept

free() a buffer in a given heap.

Parameters
addressThe address to free
countThe count of the array
sizeThe size of the Type
alignment

◆ deallocate() [2/3]

template<class TAllocator , class TFilter = basic_allocator_filter>
void mn::memory::basic_allocator< TAllocator, TFilter >::deallocate ( pointer  address,
size_t  size 
)
inlinenoexcept

free() a buffer in a given heap.

Parameters
addressThe address to free.
sizeThe size of the Type

◆ deallocate() [3/3]

template<class TAllocator , class TFilter = basic_allocator_filter>
void mn::memory::basic_allocator< TAllocator, TFilter >::deallocate ( pointer  address,
size_t  size,
size_t  alignment 
)
inlinenoexcept

free() a buffer in a given heap.

Parameters
addressThe address to free.
alignment
sizeThe size of the Type

◆ destroy()

template<class TAllocator , class TFilter = basic_allocator_filter>
template<class Type >
void mn::memory::basic_allocator< TAllocator, TFilter >::destroy ( Type *  address)
inlinenoexcept

Deconstruct a object (call deconstructor) and free the memory.

Template Parameters
TypeThe type of the object.
Parameters
addressThe pointer of the object to be deconstruct.

◆ get_max_alocator_size()

template<class TAllocator , class TFilter = basic_allocator_filter>
size_t mn::memory::basic_allocator< TAllocator, TFilter >::get_max_alocator_size ( ) const
inlinenoexcept

Get the maximal size to allocate.

Returns
The maximal size to allocate.

Member Data Documentation

◆ m_fFilter

template<class TAllocator , class TFilter = basic_allocator_filter>
filter_type mn::memory::basic_allocator< TAllocator, TFilter >::m_fFilter
private

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