KTL
ktl::fallback< P, F > Class Template Reference

An allocator which delegates allocations between 2 different allocators. It first attempts to allocate with the primary allocator, but upon failure will use the fallback allocator. More...

#include <fallback.h>

Public Types

typedef detail::get_size_type_t< P > size_type
 

Public Member Functions

 fallback ()=default
 
template<typename Primary , typename = std::enable_if_t<std::is_constructible_v<P, Primary>>>
 fallback (Primary &&primary) noexcept(std::is_nothrow_constructible_v< P, Primary > &&std::is_nothrow_default_constructible_v< F >)
 Constructor for forwarding a single argument to the primary allocator. More...
 
template<typename Primary , typename Fallback , typename = std::enable_if_t< std::is_constructible_v<P, Primary> && std::is_constructible_v<F, Fallback>>>
 fallback (Primary &&primary, Fallback &&fallback) noexcept(std::is_nothrow_constructible_v< P, Primary > &&std::is_nothrow_constructible_v< F, Fallback >)
 Constructor for forwarding a single argument to the primary and fallback allocators. More...
 
template<typename... Args, typename = std::enable_if_t< std::is_constructible_v<P, Args...>>>
 fallback (std::tuple< Args... > &&primary) noexcept(std::is_nothrow_constructible_v< P, Args... > &&std::is_nothrow_default_constructible_v< F >)
 Constructor for forwarding a tuple of arguments to the primary allocator. More...
 
template<typename... ArgsP, typename... ArgsF, typename = std::enable_if_t< std::is_constructible_v<P, ArgsP...>&& std::is_constructible_v<F, ArgsF...>>>
 fallback (std::tuple< ArgsP... > &&primary, std::tuple< ArgsF... > &&fallback) noexcept(std::is_nothrow_constructible_v< P, ArgsP... > &&std::is_nothrow_constructible_v< F, ArgsF... >)
 Constructor for forwarding a tuple of arguments to the primary and fallback allocators. More...
 
 fallback (const fallback &)=default
 
 fallback (fallback &&)=default
 
fallbackoperator= (const fallback &)=default
 
fallbackoperator= (fallback &&)=default
 
bool operator== (const fallback &rhs) const noexcept(detail::has_nothrow_equal_v< P > &&detail::has_nothrow_equal_v< F >)
 
bool operator!= (const fallback &rhs) const noexcept(detail::has_nothrow_not_equal_v< P > &&detail::has_nothrow_not_equal_v< F >)
 
void * allocate (size_t n) noexcept(detail::has_nothrow_allocate_v< P > &&detail::has_nothrow_allocate_v< F >)
 
void deallocate (void *p, size_t n) noexcept(detail::has_nothrow_deallocate_v< P > &&detail::has_nothrow_deallocate_v< F >)
 
template<typename T , typename... Args>
std::enable_if< detail::has_construct_v< P, T *, Args... >||detail::has_construct_v< F, T *, Args... >, void >::type construct (T *p, Args &&... args) noexcept((!detail::has_construct_v< P, T *, Args... >||detail::has_nothrow_construct_v< P, T *, Args... >) &&(!detail::has_construct_v< F, T *, Args... >||detail::has_nothrow_construct_v< F, T *, Args... >) &&std::is_nothrow_constructible_v< T, Args... >)
 
template<typename T >
std::enable_if< detail::has_destroy_v< P, T * >||detail::has_destroy_v< F, T * >, void >::type destroy (T *p) noexcept((!detail::has_destroy_v< P, T * >||detail::has_nothrow_destroy_v< P, T * >) &&(!detail::has_destroy_v< F, T * >||detail::has_nothrow_destroy_v< F, T * >) &&std::is_nothrow_destructible_v< T >)
 
template<typename Primary = P, typename Fallback = F>
std::enable_if< detail::has_max_size_v< Primary > &&detail::has_max_size_v< Fallback >, size_type >::type max_size () const noexcept(detail::has_nothrow_max_size_v< Primary > &&detail::has_nothrow_max_size_v< Fallback >)
 
template<typename Primary = P, typename Fallback = F>
std::enable_if< detail::has_owns_v< Primary > &&detail::has_owns_v< Fallback >, bool >::type owns (void *p) const noexcept(detail::has_nothrow_owns_v< Primary > &&detail::has_nothrow_owns_v< Fallback >)
 

Detailed Description

template<typename P, typename F>
class ktl::fallback< P, F >

An allocator which delegates allocations between 2 different allocators. It first attempts to allocate with the primary allocator, but upon failure will use the fallback allocator.

Note
The primary allocator must have an owns(*ptr) method.
Template Parameters
PThe primary allocator
FThe fallback allocator, which is used when the primary allocator fails

Member Typedef Documentation

◆ size_type

template<typename P , typename F >
typedef detail::get_size_type_t<P> ktl::fallback< P, F >::size_type

Constructor & Destructor Documentation

◆ fallback() [1/7]

template<typename P , typename F >
ktl::fallback< P, F >::fallback ( )
default

◆ fallback() [2/7]

template<typename P , typename F >
template<typename Primary , typename = std::enable_if_t<std::is_constructible_v<P, Primary>>>
ktl::fallback< P, F >::fallback ( Primary &&  primary)
inlineexplicitnoexcept

Constructor for forwarding a single argument to the primary allocator.

◆ fallback() [3/7]

template<typename P , typename F >
template<typename Primary , typename Fallback , typename = std::enable_if_t< std::is_constructible_v<P, Primary> && std::is_constructible_v<F, Fallback>>>
ktl::fallback< P, F >::fallback ( Primary &&  primary,
Fallback &&  fallback 
)
inlineexplicitnoexcept

Constructor for forwarding a single argument to the primary and fallback allocators.

◆ fallback() [4/7]

template<typename P , typename F >
template<typename... Args, typename = std::enable_if_t< std::is_constructible_v<P, Args...>>>
ktl::fallback< P, F >::fallback ( std::tuple< Args... > &&  primary)
inlineexplicitnoexcept

Constructor for forwarding a tuple of arguments to the primary allocator.

◆ fallback() [5/7]

template<typename P , typename F >
template<typename... ArgsP, typename... ArgsF, typename = std::enable_if_t< std::is_constructible_v<P, ArgsP...>&& std::is_constructible_v<F, ArgsF...>>>
ktl::fallback< P, F >::fallback ( std::tuple< ArgsP... > &&  primary,
std::tuple< ArgsF... > &&  fallback 
)
inlineexplicitnoexcept

Constructor for forwarding a tuple of arguments to the primary and fallback allocators.

◆ fallback() [6/7]

template<typename P , typename F >
ktl::fallback< P, F >::fallback ( const fallback< P, F > &  )
default

◆ fallback() [7/7]

template<typename P , typename F >
ktl::fallback< P, F >::fallback ( fallback< P, F > &&  )
default

Member Function Documentation

◆ allocate()

template<typename P , typename F >
void* ktl::fallback< P, F >::allocate ( size_t  n)
inlinenoexcept

◆ construct()

template<typename P , typename F >
template<typename T , typename... Args>
std::enable_if<detail::has_construct_v<P, T*, Args...> || detail::has_construct_v<F, T*, Args...>, void>::type ktl::fallback< P, F >::construct ( T *  p,
Args &&...  args 
)
inlinenoexcept

◆ deallocate()

template<typename P , typename F >
void ktl::fallback< P, F >::deallocate ( void *  p,
size_t  n 
)
inlinenoexcept

◆ destroy()

template<typename P , typename F >
template<typename T >
std::enable_if<detail::has_destroy_v<P, T*> || detail::has_destroy_v<F, T*>, void>::type ktl::fallback< P, F >::destroy ( T *  p)
inlinenoexcept

◆ max_size()

template<typename P , typename F >
template<typename Primary = P, typename Fallback = F>
std::enable_if<detail::has_max_size_v<Primary> && detail::has_max_size_v<Fallback>, size_type>::type ktl::fallback< P, F >::max_size ( ) const
inlinenoexcept

◆ operator!=()

template<typename P , typename F >
bool ktl::fallback< P, F >::operator!= ( const fallback< P, F > &  rhs) const
inlinenoexcept

◆ operator=() [1/2]

template<typename P , typename F >
fallback& ktl::fallback< P, F >::operator= ( const fallback< P, F > &  )
default

◆ operator=() [2/2]

template<typename P , typename F >
fallback& ktl::fallback< P, F >::operator= ( fallback< P, F > &&  )
default

◆ operator==()

template<typename P , typename F >
bool ktl::fallback< P, F >::operator== ( const fallback< P, F > &  rhs) const
inlinenoexcept

◆ owns()

template<typename P , typename F >
template<typename Primary = P, typename Fallback = F>
std::enable_if<detail::has_owns_v<Primary> && detail::has_owns_v<Fallback>, bool>::type ktl::fallback< P, F >::owns ( void *  p) const
inlinenoexcept

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