Allocator Builder
Policy Based C++ Template Allocator Library
 All Classes Functions Variables Enumerations Enumerator Groups Pages
alb::v_100::fallback_allocator< Primary, Fallback > Class Template Reference

#include <fallback_allocator.hpp>

Inherits Primary, and Fallback.

Public Member Functions

block allocate (size_t n) noexcept
 
void deallocate (block &b) noexcept
 
bool reallocate (block &b, size_t n) noexcept
 
template<typename U = Primary, typename V = Fallback>
std::enable_if
< traits::has_expand< U >
::value||traits::has_expand< V >
::value, bool >::type 
expand (block &b, size_t delta) noexcept
 
template<typename U = Primary, typename V = Fallback>
std::enable_if
< traits::has_owns< U >::value
&&traits::has_owns< V >::value,
bool >::type 
owns (const block &b) const noexcept
 
template<typename U = Primary, typename V = Fallback>
std::enable_if
< traits::has_deallocate_all
< U >::value
&&traits::has_deallocate_all
< V >::value, void >::type 
deallocate_all () noexcept
 

Static Public Attributes

static constexpr bool supports_truncated_deallocation
 
static constexpr unsigned alignment
 

Detailed Description

template<class Primary, class Fallback>
class alb::v_100::fallback_allocator< Primary, Fallback >

All allocation requests are passed to the Primary allocator. Only if this cannot fulfill the request, it is passed to the Fallback allocator

Template Parameters
PrimaryThe allocator that gets all requests by default
FallbackThe allocator that get the requests, if the Primary failed.

Definition at line 26 of file fallback_allocator.hpp.

Member Function Documentation

template<class Primary , class Fallback >
block alb::v_100::fallback_allocator< Primary, Fallback >::allocate ( size_t  n)
inlinenoexcept

Allocates the requested number of bytes.

Parameters
nThe number of bytes. Depending on the alignment of the allocator, the block might contain a bigger size

Definition at line 46 of file fallback_allocator.hpp.

template<class Primary , class Fallback >
void alb::v_100::fallback_allocator< Primary, Fallback >::deallocate ( block b)
inlinenoexcept

Frees the memory of the provided block and resets it.

Parameters
bThe block describing the memory to be freed.

Definition at line 62 of file fallback_allocator.hpp.

template<class Primary , class Fallback >
template<typename U = Primary, typename V = Fallback>
std::enable_if<traits::has_expand<U>::value || traits::has_expand<V>::value, bool>::type alb::v_100::fallback_allocator< Primary, Fallback >::expand ( block b,
size_t  delta 
)
inlinenoexcept

Expands the given block by the given amount of bytes. This method is only available if at least one of the allocators implements it

Parameters
bThe block that should be expanded
deltaThe number of bytes that should be appended
Returns
True, if the operation could be performed successful.

Definition at line 114 of file fallback_allocator.hpp.

template<class Primary , class Fallback >
template<typename U = Primary, typename V = Fallback>
std::enable_if<traits::has_owns<U>::value && traits::has_owns<V>::value, bool>::type alb::v_100::fallback_allocator< Primary, Fallback >::owns ( const block b) const
inlinenoexcept

Checks for the ownership of the given block This method is only available, if both allocators implements it.

Parameters
bThe block which ownership shall be checked.
Returns
True if the block comes from one of the allocators.

Definition at line 135 of file fallback_allocator.hpp.

template<class Primary , class Fallback >
bool alb::v_100::fallback_allocator< Primary, Fallback >::reallocate ( block b,
size_t  n 
)
inlinenoexcept

Reallocates the given block to the given size. If the Primary cannot handle the request, then a memory move is done.

Parameters
bThe block to be reallocated
nThe new size (Zero means deallocation.)
Returns
True if the operation was successful

Definition at line 80 of file fallback_allocator.hpp.

Member Data Documentation

template<class Primary , class Fallback >
constexpr unsigned alb::v_100::fallback_allocator< Primary, Fallback >::alignment
static
Initial value:
= (Primary::alignment > Fallback::alignment) ?
Primary::alignment : Fallback::alignment

Definition at line 38 of file fallback_allocator.hpp.

template<class Primary , class Fallback >
constexpr bool alb::v_100::fallback_allocator< Primary, Fallback >::supports_truncated_deallocation
static
Initial value:
= Primary::supports_truncated_deallocation ||
Fallback::supports_truncated_deallocation

Definition at line 35 of file fallback_allocator.hpp.


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