bit::memory
Public Types | Static Public Member Functions | List of all members
bit::memory::block_allocator_traits< BlockAllocator > Class Template Reference

The block_allocator_traits class template provides a standardized way to access block allocator functionality. More...

#include <block_allocator_traits.hpp>

Public Types

using has_block_alignment = block_allocator_has_default_block_alignment< BlockAllocator >
 

Static Public Member Functions

static owner< memory_blockallocate_block (BlockAllocator &alloc)
 Allocates a block from the underlying allocator. More...
 
static void deallocate_block (BlockAllocator &alloc, owner< memory_block > block)
 Deallocates a block from the underlying container. More...
 
static allocator_info info (const BlockAllocator &alloc) noexcept
 Gets the name of the specified block allocator. More...
 
static std::size_t next_block_size (const BlockAllocator &alloc) noexcept
 Gets the size of the next block from the block allocator. More...
 
static std::size_t next_block_alignment (const BlockAllocator &alloc) noexcept
 Gets the alignment of the next block from the block allocator. More...
 

Detailed Description

template<typename BlockAllocator>
class bit::memory::block_allocator_traits< BlockAllocator >

The block_allocator_traits class template provides a standardized way to access block allocator functionality.

This will infer defaults for any optional values that may not be present in the allocator

Note
In the present version of this library, BlockAllocator does not define any optional variations. This is here for forward- compatibility.
Template Parameters
BlockAllocatorthe block allocator type. Must satisfy BlockAllocator concept

Definition at line 70 of file block_allocator_traits.hpp.

Member Function Documentation

◆ allocate_block()

template<typename BlockAllocator >
static owner<memory_block> bit::memory::block_allocator_traits< BlockAllocator >::allocate_block ( BlockAllocator &  alloc)
static

Allocates a block from the underlying allocator.

Parameters
allocthe allocator to allocate from
Returns
the memory block

◆ deallocate_block()

template<typename BlockAllocator >
static void bit::memory::block_allocator_traits< BlockAllocator >::deallocate_block ( BlockAllocator &  alloc,
owner< memory_block block 
)
static

Deallocates a block from the underlying container.

Parameters
allocthe allocator to deallocate from
blockthe block to deallocate

◆ info()

template<typename BlockAllocator >
static allocator_info bit::memory::block_allocator_traits< BlockAllocator >::info ( const BlockAllocator &  alloc)
staticnoexcept

Gets the name of the specified block allocator.

Note
Not all allocators are nameable or have a name specified. For these allocators, the string returned is typeid(BlockAllocator).name()
The lifetime of the pointer returned is unmanaged, and is NOT the responsibility of the caller to free.
Parameters
allocthe block allocator to get the name of
Returns
the name of the allocator

◆ next_block_alignment()

template<typename BlockAllocator >
static std::size_t bit::memory::block_allocator_traits< BlockAllocator >::next_block_alignment ( const BlockAllocator &  alloc)
staticnoexcept

Gets the alignment of the next block from the block allocator.

If the block alignment is statically defined as 'default_alignment', then this value is returned. Otherwise it falls back to 'next_block_alignment()' if it exists; and returning '1' if it cannot be determined.

Parameters
allocthe block allocator to get the block alignment
Returns
the next block size from the allocator

◆ next_block_size()

template<typename BlockAllocator >
static std::size_t bit::memory::block_allocator_traits< BlockAllocator >::next_block_size ( const BlockAllocator &  alloc)
staticnoexcept

Gets the size of the next block from the block allocator.

Parameters
allocthe block allocator to get the block size
Returns
the next block size from the allocator

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