Metall v0.30
A persistent memory allocator for data-centric analytics
 
Loading...
Searching...
No Matches
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()).
 
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.
 
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.
 
 fallback_allocator_adaptor (const fallback_allocator_adaptor &other) noexcept=default
 Copy constructor.
 
 fallback_allocator_adaptor (fallback_allocator_adaptor &&other) noexcept=default
 Move constructor.
 
fallback_allocator_adaptoroperator= (const fallback_allocator_adaptor &) noexcept=default
 Copy assign operator.
 
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.
 
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.
 
fallback_allocator_adaptoroperator= (fallback_allocator_adaptor &&other) noexcept=default
 Move assign operator.
 
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.
 
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.
 
pointer allocate (const size_type n) const
 Allocates n * sizeof(T) bytes of storage.
 
void deallocate (pointer ptr, const size_type size) const
 Deallocates the storage reference by the pointer ptr.
 
size_type max_size () const noexcept
 The size of the theoretical maximum allocation size.
 
template<class... Args>
void construct (const pointer &ptr, Args &&...args) const
 Constructs an object of T.
 
void destroy (const pointer &ptr) const
 Deconstruct an object of T.
 
stateful_allocator_typeget_stateful_allocator ()
 Returns a reference to the stateful allocator.
 
const stateful_allocator_typeget_stateful_allocator () const
 Returns a const reference to the stateful allocator.
 
bool stateful_allocator_available () const
 Returns true if the stateful allocator is available.
 

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

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

◆ value_type

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

◆ pointer

◆ const_pointer

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

◆ void_pointer

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

◆ const_void_pointer

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

◆ difference_type

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

◆ size_type

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

Constructor & Destructor Documentation

◆ fallback_allocator_adaptor() [1/5]

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 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 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]

Copy constructor.

◆ fallback_allocator_adaptor() [5/5]

Move constructor.

Member Function Documentation

◆ operator=() [1/6]

◆ operator=() [2/6]

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

◆ operator=() [3/6]

Copy assign operator for any stateful_allocator.

◆ operator=() [4/6]

◆ operator=() [5/6]

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

◆ operator=() [6/6]

Move assign operator for any stateful_allocator.

◆ allocate()

Allocates n * sizeof(T) bytes of storage.

Parameters
nThe size to allocation
Returns
Returns a pointer

◆ deallocate()

Deallocates the storage reference by the pointer ptr.

Parameters
ptrA pointer to the storage
sizeThe size of the storage

◆ max_size()

The size of the theoretical maximum allocation size.

Returns
The size of the theoretical maximum allocation size

◆ construct()

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()

Deconstruct an object of T.

Parameters
ptrA pointer to the object

◆ get_stateful_allocator() [1/2]

Returns a reference to the stateful allocator.

◆ get_stateful_allocator() [2/2]

Returns a const reference to the stateful allocator.

◆ stateful_allocator_available()

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: