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...
|
template<typename A = Alloc> |
| freelist () noexcept(std::is_nothrow_default_constructible_v< A >) |
|
template<typename... Args, typename = std::enable_if_t< std::is_constructible_v<Alloc, Args...>>> |
| freelist (Args &&... args) noexcept(std::is_nothrow_constructible_v< Alloc, Args... >) |
| Constructor for forwarding any arguments to the underlying allocator. More...
|
|
| freelist (const freelist &)=delete |
|
| freelist (freelist &&other) noexcept(std::is_nothrow_move_constructible_v< Alloc >) |
|
| ~freelist () |
|
freelist & | operator= (const freelist &)=delete |
|
freelist & | operator= (freelist &&rhs) noexcept(std::is_nothrow_move_assignable_v< Alloc >) |
|
bool | operator== (const freelist &rhs) const noexcept(detail::has_nothrow_equal_v< Alloc >) |
|
bool | operator!= (const freelist &rhs) const noexcept(detail::has_nothrow_not_equal_v< Alloc >) |
|
void * | allocate (size_type n) noexcept(detail::has_nothrow_allocate_v< Alloc >) |
| Attempts to allocate a chunk of memory defined by n . Will use previous allocations that were meant to be deallocated. More...
|
|
void | deallocate (void *p, size_type n) noexcept |
| Attempts to deallocate the memory at location p . More...
|
|
template<typename T , typename... Args> |
std::enable_if< detail::has_construct_v< Alloc, T *, Args... >, void >::type | construct (T *p, Args &&... args) noexcept(detail::has_nothrow_construct_v< Alloc, T *, Args... >) |
| Constructs an object of T with the given ...args at the given location. More...
|
|
template<typename T > |
std::enable_if< detail::has_destroy_v< Alloc, T * >, void >::type | destroy (T *p) noexcept(detail::has_nothrow_destroy_v< Alloc, T * >) |
| Destructs an object of T at the given location. More...
|
|
template<typename A = Alloc> |
std::enable_if< detail::has_max_size_v< A >, size_type >::type | max_size () const noexcept(detail::has_nothrow_max_size_v< A >) |
| Returns the maximum size that an allocation can be. More...
|
|
template<typename A = Alloc> |
std::enable_if< detail::has_owns_v< A >, bool >::type | owns (void *p) const noexcept(detail::has_nothrow_owns_v< A >) |
| Returns whether or not the allocator owns the given location in memory. More...
|
|
Alloc & | get_allocator () noexcept |
| Returns a reference to the underlying allocator. More...
|
|
const Alloc & | get_allocator () const noexcept |
| Returns a const reference to the underlying allocator. More...
|
|
template<size_t Min, size_t Max, typename Alloc>
class ktl::freelist< Min, Max, Alloc >
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.
- Note
- The memory is only completely dealloacated when the allocator is destroyed. The value of
Max
must be at least the size of a pointer, otherwise it cannot chain deallocations.
- Template Parameters
-
Alloc | The allocator to wrap around |
template<size_t Min, size_t Max, typename Alloc >
template<typename... Args, typename = std::enable_if_t< std::is_constructible_v<Alloc, Args...>>>
Constructor for forwarding any arguments to the underlying allocator.