KTL
ktl::segragator< Threshold, P, F > Class Template Reference

An allocator which delegates allocations between 2 different allocators based on a size threshold. More...

#include <segragator.h>

Public Types

typedef detail::get_size_type_t< P > size_type
 

Public Member Functions

 segragator ()=default
 
template<typename Primary , typename = std::enable_if_t<std::is_constructible_v<P, Primary>>>
 segragator (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>>>
 segragator (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...>>>
 segragator (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...>>>
 segragator (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...
 
 segragator (const segragator &)=default
 
 segragator (segragator &&)=default
 
segragatoroperator= (const segragator &)=default
 
segragatoroperator= (segragator &&)=default
 
bool operator== (const segragator &rhs) const noexcept(detail::has_nothrow_equal_v< P > &&detail::has_nothrow_equal_v< F >)
 
bool operator!= (const segragator &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<size_t Threshold, typename P, typename F>
class ktl::segragator< Threshold, P, F >

An allocator which delegates allocations between 2 different allocators based on a size threshold.

Note
The primary allocator must have an owns(*ptr) method if it also has a construct() method.
Template Parameters
PThe primary allocator, which is used when size is less than or equal to Threshold
FThe fallback allocator, which is used when size is bigger than Threshold

Member Typedef Documentation

◆ size_type

template<size_t Threshold, typename P , typename F >
typedef detail::get_size_type_t<P> ktl::segragator< Threshold, P, F >::size_type

Constructor & Destructor Documentation

◆ segragator() [1/7]

template<size_t Threshold, typename P , typename F >
ktl::segragator< Threshold, P, F >::segragator ( )
default

◆ segragator() [2/7]

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

Constructor for forwarding a single argument to the primary allocator.

◆ segragator() [3/7]

template<size_t Threshold, 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::segragator< Threshold, P, F >::segragator ( Primary &&  primary,
Fallback &&  fallback 
)
inlineexplicitnoexcept

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

◆ segragator() [4/7]

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

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

◆ segragator() [5/7]

template<size_t Threshold, 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::segragator< Threshold, P, F >::segragator ( std::tuple< ArgsP... > &&  primary,
std::tuple< ArgsF... > &&  fallback 
)
inlineexplicitnoexcept

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

◆ segragator() [6/7]

template<size_t Threshold, typename P , typename F >
ktl::segragator< Threshold, P, F >::segragator ( const segragator< Threshold, P, F > &  )
default

◆ segragator() [7/7]

template<size_t Threshold, typename P , typename F >
ktl::segragator< Threshold, P, F >::segragator ( segragator< Threshold, P, F > &&  )
default

Member Function Documentation

◆ allocate()

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

◆ construct()

template<size_t Threshold, 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::segragator< Threshold, P, F >::construct ( T *  p,
Args &&...  args 
)
inlinenoexcept

◆ deallocate()

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

◆ destroy()

template<size_t Threshold, 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::segragator< Threshold, P, F >::destroy ( T *  p)
inlinenoexcept

◆ max_size()

template<size_t Threshold, 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::segragator< Threshold, P, F >::max_size ( ) const
inlinenoexcept

◆ operator!=()

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

◆ operator=() [1/2]

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

◆ operator=() [2/2]

template<size_t Threshold, typename P , typename F >
segragator& ktl::segragator< Threshold, P, F >::operator= ( segragator< Threshold, P, F > &&  )
default

◆ operator==()

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

◆ owns()

template<size_t Threshold, 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::segragator< Threshold, P, F >::owns ( void *  p) const
inlinenoexcept

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