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

A Metall STL compatible allocator which fallbacks to a heap allocator (e.g., malloc()) if its constructor receives no argument to construct the stateful allocator (Metall's normal STL compatible 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_allocator_type = typename std::remove_const< typename std::remove_reference< StatefulAllocator >::type >::type
 
using value_type = typename stateful_allocator_type::value_type
 
using pointer = typename stateful_allocator_type::pointer
 
using const_pointer = typename stateful_allocator_type::const_pointer
 
using void_pointer = typename stateful_allocator_type::void_pointer
 
using const_void_pointer = typename stateful_allocator_type::const_void_pointer
 
using difference_type = typename stateful_allocator_type::difference_type
 
using size_type = typename stateful_allocator_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_allocator_type2 , std::enable_if_t< std::is_constructible< stateful_allocator_type, stateful_allocator_type2 >::value, int > = 0>
 fallback_allocator_adaptor (fallback_allocator_adaptor< stateful_allocator_type2 > allocator_instance) noexcept
 Construct a new instance using an instance of fallback_allocator_adaptor with any stateful_allocator type. More...
 
template<typename stateful_allocator_type2 , std::enable_if_t< std::is_constructible< stateful_allocator_type, stateful_allocator_type2 >::value, int > = 0>
 fallback_allocator_adaptor (stateful_allocator_type2 allocator_instance) noexcept
 Construct a new instance using an instance of any stateful_allocator. 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_allocator_type2 , std::enable_if_t< std::is_constructible< stateful_allocator_type, stateful_allocator_type2 >::value, int > = 0>
fallback_allocator_adaptoroperator= (const fallback_allocator_adaptor< stateful_allocator_type2 > &other) noexcept
 Copy assign operator, using an instance of fallback_allocator_adaptor with any stateful_allocator type. More...
 
template<typename stateful_allocator_type2 , std::enable_if_t< std::is_constructible< stateful_allocator_type, stateful_allocator_type2 >::value, int > = 0>
fallback_allocator_adaptoroperator= (const stateful_allocator_type2 &allocator_instance) noexcept
 Copy assign operator for any stateful_allocator. More...
 
fallback_allocator_adaptoroperator= (fallback_allocator_adaptor &&other) noexcept=default
 Move assign operator. More...
 
template<typename stateful_allocator_type2 , std::enable_if_t< std::is_constructible< stateful_allocator_type, stateful_allocator_type2 >::value, int > = 0>
fallback_allocator_adaptoroperator= (fallback_allocator_adaptor< stateful_allocator_type2 > &&other) noexcept
 Move assign operator, using an instance of fallback_allocator_adaptor with any stateful_allocator type. More...
 
template<typename stateful_allocator_type2 , std::enable_if_t< std::is_constructible< stateful_allocator_type, stateful_allocator_type2 >::value, int > = 0>
fallback_allocator_adaptoroperator= (stateful_allocator_type2 &&allocator_instance) noexcept
 Move assign operator for any stateful_allocator. 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_allocator_typeget_stateful_allocator ()
 Returns a reference to the stateful allocator. More...
 
const stateful_allocator_typeget_stateful_allocator () const
 Returns a const reference to the stateful allocator. More...
 
bool stateful_allocator_available () const
 Returns true if the stateful allocator is available. More...
 

Detailed Description

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

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

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

Member Typedef Documentation

◆ stateful_allocator_type

template<typename StatefulAllocator >
using metall::container::fallback_allocator_adaptor< StatefulAllocator >::stateful_allocator_type = typename std::remove_const< typename std::remove_reference<StatefulAllocator>::type>::type

◆ value_type

template<typename StatefulAllocator >
using metall::container::fallback_allocator_adaptor< StatefulAllocator >::value_type = typename stateful_allocator_type::value_type

◆ pointer

template<typename StatefulAllocator >
using metall::container::fallback_allocator_adaptor< StatefulAllocator >::pointer = typename stateful_allocator_type::pointer

◆ const_pointer

template<typename StatefulAllocator >
using metall::container::fallback_allocator_adaptor< StatefulAllocator >::const_pointer = typename stateful_allocator_type::const_pointer

◆ void_pointer

template<typename StatefulAllocator >
using metall::container::fallback_allocator_adaptor< StatefulAllocator >::void_pointer = typename stateful_allocator_type::void_pointer

◆ const_void_pointer

template<typename StatefulAllocator >
using metall::container::fallback_allocator_adaptor< StatefulAllocator >::const_void_pointer = typename stateful_allocator_type::const_void_pointer

◆ difference_type

template<typename StatefulAllocator >
using metall::container::fallback_allocator_adaptor< StatefulAllocator >::difference_type = typename stateful_allocator_type::difference_type

◆ size_type

template<typename StatefulAllocator >
using metall::container::fallback_allocator_adaptor< StatefulAllocator >::size_type = typename stateful_allocator_type::size_type

Constructor & Destructor Documentation

◆ fallback_allocator_adaptor() [1/5]

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

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

◆ fallback_allocator_adaptor() [2/5]

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

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

◆ fallback_allocator_adaptor() [3/5]

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

Construct a new instance using an instance of any stateful_allocator.

◆ fallback_allocator_adaptor() [4/5]

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

Copy constructor.

◆ fallback_allocator_adaptor() [5/5]

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

Move constructor.

Member Function Documentation

◆ operator=() [1/6]

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

Copy assign operator.

◆ operator=() [2/6]

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

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

◆ operator=() [3/6]

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

Copy assign operator for any stateful_allocator.

◆ operator=() [4/6]

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

Move assign operator.

◆ operator=() [5/6]

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

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

◆ operator=() [6/6]

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

Move assign operator for any stateful_allocator.

◆ allocate()

template<typename StatefulAllocator >
pointer metall::container::fallback_allocator_adaptor< StatefulAllocator >::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 StatefulAllocator >
void metall::container::fallback_allocator_adaptor< StatefulAllocator >::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 StatefulAllocator >
size_type metall::container::fallback_allocator_adaptor< StatefulAllocator >::max_size ( ) const
inlinenoexcept

The size of the theoretical maximum allocation size.

Returns
The size of the theoretical maximum allocation size

◆ construct()

template<typename StatefulAllocator >
template<class... Args>
void metall::container::fallback_allocator_adaptor< StatefulAllocator >::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 StatefulAllocator >
void metall::container::fallback_allocator_adaptor< StatefulAllocator >::destroy ( const pointer ptr) const
inline

Deconstruct an object of T.

Parameters
ptrA pointer to the object

◆ get_stateful_allocator() [1/2]

template<typename StatefulAllocator >
stateful_allocator_type& metall::container::fallback_allocator_adaptor< StatefulAllocator >::get_stateful_allocator ( )
inline

Returns a reference to the stateful allocator.

◆ get_stateful_allocator() [2/2]

template<typename StatefulAllocator >
const stateful_allocator_type& metall::container::fallback_allocator_adaptor< StatefulAllocator >::get_stateful_allocator ( ) const
inline

Returns a const reference to the stateful allocator.

◆ stateful_allocator_available()

template<typename StatefulAllocator >
bool metall::container::fallback_allocator_adaptor< StatefulAllocator >::stateful_allocator_available ( ) const
inline

Returns true if the stateful allocator is available.

Returns
Returns true if the stateful allocator is available.

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