KTL
ktl Namespace Reference

Namespaces

 detail
 

Classes

class  cascading
 An allocator which owns multiple instances of a given sub allocator. When allocating it will attempt to use the first available allocator. Upon failure it will instead create a new instance and allocate from it. More...
 
class  fallback
 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...
 
class  type_allocator
 Wrapper class for making an untyped allocator into a typed allocator. More...
 
class  freelist
 An allocator which allocates using its underlying allocator. Only allocates if the requested size is within the Min and Max range When deallocating it chains the memory in a linked list, which can then be reused. More...
 
class  global
 
class  linear_allocator
 A linear allocator which gives out chunks of its internal stack. Increments a counter during allocation, which makes it very fast but also unlikely to deallocate it again. Has a max allocation size of the Size given. More...
 
class  mallocator
 An allocator which uses an aligned malloc for allocation. More...
 
class  null_allocator
 An allocator which does nothing. Useful for debugging composite allocators, like ensuring a specific path in a composite allocator is not used. More...
 
class  overflow
 
class  reference
 
class  segragator
 An allocator which delegates allocations between 2 different allocators based on a size threshold. More...
 
class  notomic
 
class  shared
 
struct  stack
 A stack object of a given Size. More...
 
class  stack_allocator
 A linear allocator which gives out chunks of its allocated stack. Increments a counter during allocation, which makes it very fast but also unlikely to deallocate it again. Has a max allocation size of the Size given. More...
 
class  threaded
 
class  binary_heap
 A priority queue implemented as a binary heap. More...
 
class  packed_ptr
 A packed pointer-like type which takes advantage of any bits that don't get used due to alignment. More...
 
class  trivial_array
 A dynamically alloacted array of trivial types. More...
 
class  trivial_buffer
 
class  trivial_vector
 A dynamically allocated vector or trivial types. More...
 

Typedefs

template<typename T , typename Alloc >
using type_cascading_allocator = type_allocator< T, cascading< Alloc > >
 Shorthand for a typed cascading allocator. More...
 
template<typename T , typename Alloc >
using type_shared_cascading_allocator = type_allocator< T, shared< cascading< Alloc > >>
 Shorthand for a typed, ref-counted cascading allocator. More...
 
template<typename... Ts>
using fallback_builder_min = typename detail::fallback_builder< false, std::tuple< Ts... > >::type
 A type builder for a left-leaning fallback allocator. More...
 
template<typename... Ts>
using fallback_builder_max = typename detail::fallback_builder< true, std::tuple< Ts... > >::type
 A type builder for a right-leaning fallback allocator. More...
 
template<typename T , typename P , typename F >
using type_fallback_allocator = type_allocator< T, fallback< P, F > >
 Shorthand for a typed fallback allocator. More...
 
template<typename T , typename P , typename F >
using type_shared_fallback_allocator = type_allocator< T, shared< fallback< P, F > >>
 Shorthand for a typed, ref-counted fallback allocator. More...
 
template<typename T , size_t Min, size_t Max, typename Alloc >
using type_freelist_allocator = type_allocator< T, freelist< Min, Max, Alloc > >
 Shorthand for a typed freelist allocator. More...
 
template<typename T , size_t Min, size_t Max, typename Alloc >
using type_shared_freelist_allocator = type_allocator< T, shared< freelist< Min, Max, Alloc > >>
 Shorthand for a typed, ref-counted freelist allocator. More...
 
template<typename T , size_t Size>
using type_linear_allocator = type_allocator< T, linear_allocator< Size > >
 Shorthand for a typed linear allocator. More...
 
template<typename T , size_t Size>
using type_reference_linear_allocator = type_allocator< T, reference< linear_allocator< Size > >>
 Shorthand for a typed, weak-reference linear allocator. More...
 
template<typename T , size_t Size>
using type_shared_linear_allocator = type_allocator< T, shared< linear_allocator< Size > >>
 Shorthand for a typed, ref-counted linear allocator. More...
 
template<typename T >
using type_mallocator = type_allocator< T, mallocator >
 Shorthand for a typed mallocator. More...
 
template<typename T , typename Alloc , typename Stream = std::ostream>
using type_overflow_allocator = type_allocator< T, overflow< Alloc, Stream > >
 Shorthand for a typed overflow allocator. More...
 
template<typename T , typename Alloc , typename Stream = std::ostream>
using type_shared_overflow_allocator = type_allocator< T, shared< overflow< Alloc, Stream > >>
 Shorthand for a typed, ref-counted overflow allocator. More...
 
template<typename ... Ts>
using segragator_builder_min = typename detail::segragator_builder< false, std::tuple< Ts... > >::type
 A type builder for a left-leaning segragator allocator. More...
 
template<typename ... Ts>
using segragator_builder_max = typename detail::segragator_builder< true, std::tuple< Ts... > >::type
 A type builder for a right-leaning segragator allocator. More...
 
template<size_t N>
using threshold = std::integral_constant< size_t, N >
 A shorthand way of writing std::integral_constant<size_t, N> More...
 
template<typename T , size_t Threshold, typename P , typename F >
using type_segragator_allocator = type_allocator< T, segragator< Threshold, P, F > >
 Shorthand for a typed segragator allocator. More...
 
template<typename T , size_t Threshold, typename P , typename F >
using type_reference_segragator_allocator = type_allocator< T, reference< segragator< Threshold, P, F > >>
 Shorthand for a typed, weak-reference segragator allocator. More...
 
template<typename T , size_t Threshold, typename P , typename F >
using type_shared_segragator_allocator = type_allocator< T, shared< segragator< Threshold, P, F > >>
 Shorthand for a typed, ref-counted segragator allocator. More...
 
template<typename Alloc >
using atomic_shared = shared< Alloc, std::atomic >
 Shorthand for an atomic-ref-counted allocator. More...
 
template<typename T , typename Alloc >
using type_shared = type_allocator< T, shared< Alloc > >
 Shorthand for a typed, ref-counted allocator. More...
 
template<typename T , typename Alloc >
using type_atomic_shared = type_allocator< T, atomic_shared< Alloc > >
 Shorthand for a typed, atomic-ref-counted allocator. More...
 
template<typename T , size_t Size>
using type_stack_allocator = type_allocator< T, stack_allocator< Size > >
 Shorthand for a typed stack allocator. More...
 
template<typename T , size_t Size>
using type_shared_stack_allocator = type_allocator< T, shared< stack_allocator< Size > >>
 Shorthand for a typed, ref-counted stack allocator. More...
 
template<typename T , typename Alloc >
using type_shared_threaded = type_allocator< T, atomic_shared< threaded< Alloc > >>
 Shorthand for a typed, ref-counted thread-safe allocator. More...
 
template<typename T , typename Alloc = std::allocator<T>>
using binary_min_heap = binary_heap< T, std::less< T >, Alloc >
 An implementation of a binary min heap, using std::less<T> More...
 
template<typename T , typename Alloc = std::allocator<T>>
using binary_max_heap = binary_heap< T, std::greater< T >, Alloc >
 An implementation of a binary max heap, using std::greater<T> More...
 

Functions

template<typename T , typename U , typename Alloc >
bool operator== (const type_allocator< T, Alloc > &lhs, const type_allocator< U, Alloc > &rhs) noexcept(detail::has_nothrow_equal_v< Alloc >)
 
template<typename T , typename U , typename Alloc >
bool operator!= (const type_allocator< T, Alloc > &lhs, const type_allocator< U, Alloc > &rhs) noexcept(detail::has_nothrow_not_equal_v< Alloc >)
 

Typedef Documentation

◆ atomic_shared

template<typename Alloc >
using ktl::atomic_shared = typedef shared<Alloc, std::atomic>

Shorthand for an atomic-ref-counted allocator.

◆ binary_max_heap

template<typename T , typename Alloc = std::allocator<T>>
using ktl::binary_max_heap = typedef binary_heap<T, std::greater<T>, Alloc>

An implementation of a binary max heap, using std::greater<T>

Template Parameters
TThe type to use. Must be move constructible and move assignable
AllocThe type of allocoator to use

◆ binary_min_heap

template<typename T , typename Alloc = std::allocator<T>>
using ktl::binary_min_heap = typedef binary_heap<T, std::less<T>, Alloc>

An implementation of a binary min heap, using std::less<T>

Template Parameters
TThe type to use. Must be move constructible and move assignable
AllocThe type of allocoator to use

◆ fallback_builder_max

template<typename... Ts>
using ktl::fallback_builder_max = typedef typename detail::fallback_builder<true, std::tuple<Ts...> >::type

A type builder for a right-leaning fallback allocator.

Template Parameters
...TsVarious allocators, in descending order

◆ fallback_builder_min

template<typename... Ts>
using ktl::fallback_builder_min = typedef typename detail::fallback_builder<false, std::tuple<Ts...> >::type

A type builder for a left-leaning fallback allocator.

Template Parameters
...TsVarious allocators, in descending order

◆ segragator_builder_max

template<typename ... Ts>
using ktl::segragator_builder_max = typedef typename detail::segragator_builder<true, std::tuple<Ts...> >::type

A type builder for a right-leaning segragator allocator.

Note
The amount of thresholds must be 1 less than the amount of allocators
Template Parameters
...TsVarious allocators and thresholds, in descending order

◆ segragator_builder_min

template<typename ... Ts>
using ktl::segragator_builder_min = typedef typename detail::segragator_builder<false, std::tuple<Ts...> >::type

A type builder for a left-leaning segragator allocator.

Note
The amount of thresholds must be 1 less than the amount of allocators
Template Parameters
...TsVarious allocators and thresholds, in descending order

◆ threshold

template<size_t N>
using ktl::threshold = typedef std::integral_constant<size_t, N>

A shorthand way of writing std::integral_constant<size_t, N>

◆ type_atomic_shared

template<typename T , typename Alloc >
using ktl::type_atomic_shared = typedef type_allocator<T, atomic_shared<Alloc> >

Shorthand for a typed, atomic-ref-counted allocator.

◆ type_cascading_allocator

template<typename T , typename Alloc >
using ktl::type_cascading_allocator = typedef type_allocator<T, cascading<Alloc> >

Shorthand for a typed cascading allocator.

◆ type_fallback_allocator

template<typename T , typename P , typename F >
using ktl::type_fallback_allocator = typedef type_allocator<T, fallback<P, F> >

Shorthand for a typed fallback allocator.

◆ type_freelist_allocator

template<typename T , size_t Min, size_t Max, typename Alloc >
using ktl::type_freelist_allocator = typedef type_allocator<T, freelist<Min, Max, Alloc> >

Shorthand for a typed freelist allocator.

◆ type_linear_allocator

template<typename T , size_t Size>
using ktl::type_linear_allocator = typedef type_allocator<T, linear_allocator<Size> >

Shorthand for a typed linear allocator.

◆ type_mallocator

template<typename T >
using ktl::type_mallocator = typedef type_allocator<T, mallocator>

Shorthand for a typed mallocator.

◆ type_overflow_allocator

template<typename T , typename Alloc , typename Stream = std::ostream>
using ktl::type_overflow_allocator = typedef type_allocator<T, overflow<Alloc, Stream> >

Shorthand for a typed overflow allocator.

◆ type_reference_linear_allocator

template<typename T , size_t Size>
using ktl::type_reference_linear_allocator = typedef type_allocator<T, reference<linear_allocator<Size> >>

Shorthand for a typed, weak-reference linear allocator.

◆ type_reference_segragator_allocator

template<typename T , size_t Threshold, typename P , typename F >
using ktl::type_reference_segragator_allocator = typedef type_allocator<T, reference<segragator<Threshold, P, F> >>

Shorthand for a typed, weak-reference segragator allocator.

◆ type_segragator_allocator

template<typename T , size_t Threshold, typename P , typename F >
using ktl::type_segragator_allocator = typedef type_allocator<T, segragator<Threshold, P, F> >

Shorthand for a typed segragator allocator.

◆ type_shared

template<typename T , typename Alloc >
using ktl::type_shared = typedef type_allocator<T, shared<Alloc> >

Shorthand for a typed, ref-counted allocator.

◆ type_shared_cascading_allocator

template<typename T , typename Alloc >
using ktl::type_shared_cascading_allocator = typedef type_allocator<T, shared<cascading<Alloc> >>

Shorthand for a typed, ref-counted cascading allocator.

◆ type_shared_fallback_allocator

template<typename T , typename P , typename F >
using ktl::type_shared_fallback_allocator = typedef type_allocator<T, shared<fallback<P, F> >>

Shorthand for a typed, ref-counted fallback allocator.

◆ type_shared_freelist_allocator

template<typename T , size_t Min, size_t Max, typename Alloc >
using ktl::type_shared_freelist_allocator = typedef type_allocator<T, shared<freelist<Min, Max, Alloc> >>

Shorthand for a typed, ref-counted freelist allocator.

◆ type_shared_linear_allocator

template<typename T , size_t Size>
using ktl::type_shared_linear_allocator = typedef type_allocator<T, shared<linear_allocator<Size> >>

Shorthand for a typed, ref-counted linear allocator.

◆ type_shared_overflow_allocator

template<typename T , typename Alloc , typename Stream = std::ostream>
using ktl::type_shared_overflow_allocator = typedef type_allocator<T, shared<overflow<Alloc, Stream> >>

Shorthand for a typed, ref-counted overflow allocator.

◆ type_shared_segragator_allocator

template<typename T , size_t Threshold, typename P , typename F >
using ktl::type_shared_segragator_allocator = typedef type_allocator<T, shared<segragator<Threshold, P, F> >>

Shorthand for a typed, ref-counted segragator allocator.

◆ type_shared_stack_allocator

template<typename T , size_t Size>
using ktl::type_shared_stack_allocator = typedef type_allocator<T, shared<stack_allocator<Size> >>

Shorthand for a typed, ref-counted stack allocator.

◆ type_shared_threaded

template<typename T , typename Alloc >
using ktl::type_shared_threaded = typedef type_allocator<T, atomic_shared<threaded<Alloc> >>

Shorthand for a typed, ref-counted thread-safe allocator.

◆ type_stack_allocator

template<typename T , size_t Size>
using ktl::type_stack_allocator = typedef type_allocator<T, stack_allocator<Size> >

Shorthand for a typed stack allocator.

Function Documentation

◆ operator!=()

template<typename T , typename U , typename Alloc >
bool ktl::operator!= ( const type_allocator< T, Alloc > &  lhs,
const type_allocator< U, Alloc > &  rhs 
)
noexcept

◆ operator==()

template<typename T , typename U , typename Alloc >
bool ktl::operator== ( const type_allocator< T, Alloc > &  lhs,
const type_allocator< U, Alloc > &  rhs 
)
noexcept