Metall  v0.28
A persistent memory allocator for data-centric analytics
metall::container::fallback_allocator_adaptor< stateful_allocator > Class Template Reference

A STL compatible allocator which fallbacks to a heap allocator (e.g., malloc()) if its constructor receives no argument to construct the stateful allocator instance. More...

#include </home/runner/work/metall/metall/include/metall/container/fallback_allocator.hpp>

Classes

struct  rebind
 Makes another allocator type for type T2. More...
 

Public Types

using stateful_allocatorator_type = typename std::remove_const< typename std::remove_reference< stateful_allocator >::type >::type
 
using value_type = typename stateful_allocatorator_type::value_type
 
using pointer = typename stateful_allocatorator_type::pointer
 
using const_pointer = typename stateful_allocatorator_type::const_pointer
 
using void_pointer = typename stateful_allocatorator_type::void_pointer
 
using const_void_pointer = typename stateful_allocatorator_type::const_void_pointer
 
using difference_type = typename stateful_allocatorator_type::difference_type
 
using size_type = typename stateful_allocatorator_type::size_type
 

Public Member Functions

 fallback_allocator_adaptor () noexcept
 Default constructor which falls back on the regular allocator (i.e., malloc()). More...
 
template<typename stateful_allocatorator_type2 , std::enable_if_t< std::is_constructible< stateful_allocator, stateful_allocatorator_type2 >::value, int > = 0>
 fallback_allocator_adaptor (fallback_allocator_adaptor< stateful_allocatorator_type2 > allocator_instance) noexcept
 Construct a new instance using an instance of fallback_allocator_adaptor with any stateful_allocatorator type. More...
 
template<typename stateful_allocatorator_type2 , std::enable_if_t< std::is_constructible< stateful_allocator, stateful_allocatorator_type2 >::value, int > = 0>
 fallback_allocator_adaptor (stateful_allocatorator_type2 allocator_instance) noexcept
 Construct a new instance using an instance of any stateful_allocatorator. More...
 
 fallback_allocator_adaptor (const fallback_allocator_adaptor &other) noexcept=default
 Copy constructor. More...
 
 fallback_allocator_adaptor (fallback_allocator_adaptor &&other) noexcept=default
 Move constructor. More...
 
fallback_allocator_adaptoroperator= (const fallback_allocator_adaptor &) noexcept=default
 Copy assign operator. More...
 
template<typename stateful_allocatorator_type2 , std::enable_if_t< std::is_constructible< stateful_allocator, stateful_allocatorator_type2 >::value, int > = 0>
fallback_allocator_adaptoroperator= (const fallback_allocator_adaptor< stateful_allocatorator_type2 > &other) noexcept
 Copy assign operator, using an instance of fallback_allocator_adaptor with any stateful_allocatorator type. More...
 
template<typename stateful_allocatorator_type2 , std::enable_if_t< std::is_constructible< stateful_allocator, stateful_allocatorator_type2 >::value, int > = 0>
fallback_allocator_adaptoroperator= (const stateful_allocatorator_type2 &allocator_instance) noexcept
 Copy assign operator for any stateful_allocatorator. More...
 
fallback_allocator_adaptoroperator= (fallback_allocator_adaptor &&other) noexcept=default
 Move assign operator. More...
 
template<typename stateful_allocatorator_type2 , std::enable_if_t< std::is_constructible< stateful_allocator, stateful_allocatorator_type2 >::value, int > = 0>
fallback_allocator_adaptoroperator= (fallback_allocator_adaptor< stateful_allocatorator_type2 > &&other) noexcept
 Move assign operator, using an instance of fallback_allocator_adaptor with any stateful_allocatorator type. More...
 
template<typename stateful_allocatorator_type2 , std::enable_if_t< std::is_constructible< stateful_allocator, stateful_allocatorator_type2 >::value, int > = 0>
fallback_allocator_adaptoroperator= (stateful_allocatorator_type2 &&allocator_instance) noexcept
 Move assign operator for any stateful_allocatorator. More...
 
pointer allocate (const size_type n) const
 Allocates n * sizeof(T) bytes of storage. More...
 
void deallocate (pointer ptr, const size_type size) const
 Deallocates the storage reference by the pointer ptr. More...
 
size_type max_size () const noexcept
 The size of the theoretical maximum allocation size. More...
 
template<class... Args>
void construct (const pointer &ptr, Args &&...args) const
 Constructs an object of T. More...
 
void destroy (const pointer &ptr) const
 Deconstruct an object of T. More...
 
stateful_allocatorator_typestateful_allocatorator ()
 
const stateful_allocatorator_typestateful_allocatorator () const
 

Detailed Description

template<typename stateful_allocator>
class metall::container::fallback_allocator_adaptor< stateful_allocator >

A STL compatible allocator which fallbacks to a heap allocator (e.g., malloc()) if its constructor receives no argument to construct the stateful allocator instance.

Template Parameters
stateful_allocatorThe stateful allocator type. It must not be default constructible.

Member Typedef Documentation

◆ stateful_allocatorator_type

template<typename stateful_allocator >
using metall::container::fallback_allocator_adaptor< stateful_allocator >::stateful_allocatorator_type = typename std::remove_const< typename std::remove_reference<stateful_allocator>::type>::type

◆ value_type

template<typename stateful_allocator >
using metall::container::fallback_allocator_adaptor< stateful_allocator >::value_type = typename stateful_allocatorator_type::value_type

◆ pointer

template<typename stateful_allocator >
using metall::container::fallback_allocator_adaptor< stateful_allocator >::pointer = typename stateful_allocatorator_type::pointer

◆ const_pointer

template<typename stateful_allocator >
using metall::container::fallback_allocator_adaptor< stateful_allocator >::const_pointer = typename stateful_allocatorator_type::const_pointer

◆ void_pointer

template<typename stateful_allocator >
using metall::container::fallback_allocator_adaptor< stateful_allocator >::void_pointer = typename stateful_allocatorator_type::void_pointer

◆ const_void_pointer

template<typename stateful_allocator >
using metall::container::fallback_allocator_adaptor< stateful_allocator >::const_void_pointer = typename stateful_allocatorator_type::const_void_pointer

◆ difference_type

template<typename stateful_allocator >
using metall::container::fallback_allocator_adaptor< stateful_allocator >::difference_type = typename stateful_allocatorator_type::difference_type

◆ size_type

template<typename stateful_allocator >
using metall::container::fallback_allocator_adaptor< stateful_allocator >::size_type = typename stateful_allocatorator_type::size_type

Constructor & Destructor Documentation

◆ fallback_allocator_adaptor() [1/5]

template<typename stateful_allocator >
metall::container::fallback_allocator_adaptor< stateful_allocator >::fallback_allocator_adaptor ( )
inlinenoexcept

Default constructor which falls back on the regular allocator (i.e., malloc()).

◆ fallback_allocator_adaptor() [2/5]

template<typename stateful_allocator >
template<typename stateful_allocatorator_type2 , std::enable_if_t< std::is_constructible< stateful_allocator, stateful_allocatorator_type2 >::value, int > = 0>
metall::container::fallback_allocator_adaptor< stateful_allocator >::fallback_allocator_adaptor ( fallback_allocator_adaptor< stateful_allocatorator_type2 >  allocator_instance)
inlinenoexcept

Construct a new instance using an instance of fallback_allocator_adaptor with any stateful_allocatorator type.

◆ fallback_allocator_adaptor() [3/5]

template<typename stateful_allocator >
template<typename stateful_allocatorator_type2 , std::enable_if_t< std::is_constructible< stateful_allocator, stateful_allocatorator_type2 >::value, int > = 0>
metall::container::fallback_allocator_adaptor< stateful_allocator >::fallback_allocator_adaptor ( stateful_allocatorator_type2  allocator_instance)
inlinenoexcept

Construct a new instance using an instance of any stateful_allocatorator.

◆ fallback_allocator_adaptor() [4/5]

template<typename stateful_allocator >
metall::container::fallback_allocator_adaptor< stateful_allocator >::fallback_allocator_adaptor ( const fallback_allocator_adaptor< stateful_allocator > &  other)
defaultnoexcept

Copy constructor.

◆ fallback_allocator_adaptor() [5/5]

template<typename stateful_allocator >
metall::container::fallback_allocator_adaptor< stateful_allocator >::fallback_allocator_adaptor ( fallback_allocator_adaptor< stateful_allocator > &&  other)
defaultnoexcept

Move constructor.

Member Function Documentation

◆ operator=() [1/6]

template<typename stateful_allocator >
fallback_allocator_adaptor& metall::container::fallback_allocator_adaptor< stateful_allocator >::operator= ( const fallback_allocator_adaptor< stateful_allocator > &  )
defaultnoexcept

Copy assign operator.

◆ operator=() [2/6]

template<typename stateful_allocator >
template<typename stateful_allocatorator_type2 , std::enable_if_t< std::is_constructible< stateful_allocator, stateful_allocatorator_type2 >::value, int > = 0>
fallback_allocator_adaptor& metall::container::fallback_allocator_adaptor< stateful_allocator >::operator= ( const fallback_allocator_adaptor< stateful_allocatorator_type2 > &  other)
inlinenoexcept

Copy assign operator, using an instance of fallback_allocator_adaptor with any stateful_allocatorator type.

◆ operator=() [3/6]

template<typename stateful_allocator >
template<typename stateful_allocatorator_type2 , std::enable_if_t< std::is_constructible< stateful_allocator, stateful_allocatorator_type2 >::value, int > = 0>
fallback_allocator_adaptor& metall::container::fallback_allocator_adaptor< stateful_allocator >::operator= ( const stateful_allocatorator_type2 &  allocator_instance)
inlinenoexcept

Copy assign operator for any stateful_allocatorator.

◆ operator=() [4/6]

template<typename stateful_allocator >
fallback_allocator_adaptor& metall::container::fallback_allocator_adaptor< stateful_allocator >::operator= ( fallback_allocator_adaptor< stateful_allocator > &&  other)
defaultnoexcept

Move assign operator.

◆ operator=() [5/6]

template<typename stateful_allocator >
template<typename stateful_allocatorator_type2 , std::enable_if_t< std::is_constructible< stateful_allocator, stateful_allocatorator_type2 >::value, int > = 0>
fallback_allocator_adaptor& metall::container::fallback_allocator_adaptor< stateful_allocator >::operator= ( fallback_allocator_adaptor< stateful_allocatorator_type2 > &&  other)
inlinenoexcept

Move assign operator, using an instance of fallback_allocator_adaptor with any stateful_allocatorator type.

◆ operator=() [6/6]

template<typename stateful_allocator >
template<typename stateful_allocatorator_type2 , std::enable_if_t< std::is_constructible< stateful_allocator, stateful_allocatorator_type2 >::value, int > = 0>
fallback_allocator_adaptor& metall::container::fallback_allocator_adaptor< stateful_allocator >::operator= ( stateful_allocatorator_type2 &&  allocator_instance)
inlinenoexcept

Move assign operator for any stateful_allocatorator.

◆ allocate()

template<typename stateful_allocator >
pointer metall::container::fallback_allocator_adaptor< stateful_allocator >::allocate ( const size_type  n) const
inline

Allocates n * sizeof(T) bytes of storage.

Parameters
nThe size to allocation
Returns
Returns a pointer

◆ deallocate()

template<typename stateful_allocator >
void metall::container::fallback_allocator_adaptor< stateful_allocator >::deallocate ( pointer  ptr,
const size_type  size 
) const
inline

Deallocates the storage reference by the pointer ptr.

Parameters
ptrA pointer to the storage
sizeThe size of the storage

◆ max_size()

template<typename stateful_allocator >
size_type metall::container::fallback_allocator_adaptor< stateful_allocator >::max_size ( ) const
inlinenoexcept

The size of the theoretical maximum allocation size.

Returns
The size of the theoretical maximum allocation size

◆ construct()

template<typename stateful_allocator >
template<class... Args>
void metall::container::fallback_allocator_adaptor< stateful_allocator >::construct ( const pointer ptr,
Args &&...  args 
) const
inline

Constructs an object of T.

Template Parameters
ArgsThe types of the constructor arguments
Parameters
ptrA pointer to allocated storage
argsThe constructor arguments to use

◆ destroy()

template<typename stateful_allocator >
void metall::container::fallback_allocator_adaptor< stateful_allocator >::destroy ( const pointer ptr) const
inline

Deconstruct an object of T.

Parameters
ptrA pointer to the object

◆ stateful_allocatorator() [1/2]

template<typename stateful_allocator >
stateful_allocatorator_type& metall::container::fallback_allocator_adaptor< stateful_allocator >::stateful_allocatorator ( )
inline

◆ stateful_allocatorator() [2/2]

template<typename stateful_allocator >
const stateful_allocatorator_type& metall::container::fallback_allocator_adaptor< stateful_allocator >::stateful_allocatorator ( ) const
inline

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