bit::memory
Public Types | Public Member Functions | List of all members
bit::memory::static_block_allocator< BlockSize, Blocks, Align, Tag > Class Template Reference

This is a block allocator that distributes blocks of memory stored statically. More...

#include <static_block_allocator.hpp>

Public Types

using block_size = std::integral_constant< std::size_t, BlockSize >
 
using block_alignment = std::integral_constant< std::size_t, Align >
 

Public Member Functions

 static_block_allocator () noexcept=default
 Default constructs a static_block_allocator.
 
 static_block_allocator (static_block_allocator &&other) noexcept=default
 Move-constructs a static_block_allocator from another one. More...
 
 static_block_allocator (const static_block_allocator &other) noexcept=default
 Copy-constructs a static_block_allocator from another one. More...
 
static_block_allocatoroperator= (static_block_allocator &&other) noexcept=default
 Move-assigns a static_block_allocator from another one. More...
 
static_block_allocatoroperator= (const static_block_allocator &other) noexcept=default
 Move-assigns a static_block_allocator from another one. More...
 
owner< memory_blockallocate_block () noexcept
 Allocates a memory block of size Size. More...
 
void deallocate_block (owner< memory_block > block) noexcept
 Deallocates a given memory_block. More...
 
std::size_t next_block_size () const noexcept
 Queries the next block size expected from this allocator. More...
 
allocator_info info () const noexcept
 Gets the info about this allocator. More...
 

Detailed Description

template<std::size_t BlockSize, std::size_t Blocks = 1, std::size_t Align = alignof(std::max_align_t), typename Tag = void>
class bit::memory::static_block_allocator< BlockSize, Blocks, Align, Tag >

This is a block allocator that distributes blocks of memory stored statically.

This type is templated on both the size of the static block, and an additional Tag type that may be used to create individual instantiations

Note
Since this type creates static storage data, two instantiations with the same size/tag will point to the same data – hence the ability to use type-tagging to produce unique instances.
Template Parameters
BlockSizethe size of the static allocation
Blocksthe number of blocks
Alignthe alignment of the blocks
Tagthe type used for a tag
Satisfies
BlockAllocator
Satisfies
Stateless

Definition at line 73 of file static_block_allocator.hpp.

Constructor & Destructor Documentation

◆ static_block_allocator() [1/2]

template<std::size_t BlockSize, std::size_t Blocks = 1, std::size_t Align = alignof(std::max_align_t), typename Tag = void>
bit::memory::static_block_allocator< BlockSize, Blocks, Align, Tag >::static_block_allocator ( static_block_allocator< BlockSize, Blocks, Align, Tag > &&  other)
defaultnoexcept

Move-constructs a static_block_allocator from another one.

Parameters
otherthe other allocator to move

◆ static_block_allocator() [2/2]

template<std::size_t BlockSize, std::size_t Blocks = 1, std::size_t Align = alignof(std::max_align_t), typename Tag = void>
bit::memory::static_block_allocator< BlockSize, Blocks, Align, Tag >::static_block_allocator ( const static_block_allocator< BlockSize, Blocks, Align, Tag > &  other)
defaultnoexcept

Copy-constructs a static_block_allocator from another one.

Parameters
otherthe other allocator to copy

Member Function Documentation

◆ allocate_block()

template<std::size_t BlockSize, std::size_t Blocks = 1, std::size_t Align = alignof(std::max_align_t), typename Tag = void>
owner<memory_block> bit::memory::static_block_allocator< BlockSize, Blocks, Align, Tag >::allocate_block ( )
noexcept

Allocates a memory block of size Size.

Returns
a newly allocated memory_block

◆ deallocate_block()

template<std::size_t BlockSize, std::size_t Blocks = 1, std::size_t Align = alignof(std::max_align_t), typename Tag = void>
void bit::memory::static_block_allocator< BlockSize, Blocks, Align, Tag >::deallocate_block ( owner< memory_block block)
noexcept

Deallocates a given memory_block.

Parameters
blockthe block to deallocate

◆ info()

template<std::size_t BlockSize, std::size_t Blocks = 1, std::size_t Align = alignof(std::max_align_t), typename Tag = void>
allocator_info bit::memory::static_block_allocator< BlockSize, Blocks, Align, Tag >::info ( ) const
noexcept

Gets the info about this allocator.

This defaults to 'static_block_allocator'. Use a named_static_block_allocator to override this

Returns
the info for this allocator

◆ next_block_size()

template<std::size_t BlockSize, std::size_t Blocks = 1, std::size_t Align = alignof(std::max_align_t), typename Tag = void>
std::size_t bit::memory::static_block_allocator< BlockSize, Blocks, Align, Tag >::next_block_size ( ) const
noexcept

Queries the next block size expected from this allocator.

Returns
the size of the next allocated block

◆ operator=() [1/2]

template<std::size_t BlockSize, std::size_t Blocks = 1, std::size_t Align = alignof(std::max_align_t), typename Tag = void>
static_block_allocator& bit::memory::static_block_allocator< BlockSize, Blocks, Align, Tag >::operator= ( static_block_allocator< BlockSize, Blocks, Align, Tag > &&  other)
defaultnoexcept

Move-assigns a static_block_allocator from another one.

Parameters
otherthe other allocator to move
Returns
reference to (*this)

◆ operator=() [2/2]

template<std::size_t BlockSize, std::size_t Blocks = 1, std::size_t Align = alignof(std::max_align_t), typename Tag = void>
static_block_allocator& bit::memory::static_block_allocator< BlockSize, Blocks, Align, Tag >::operator= ( const static_block_allocator< BlockSize, Blocks, Align, Tag > &  other)
defaultnoexcept

Move-assigns a static_block_allocator from another one.

Parameters
otherthe other allocator to move
Returns
reference to (*this)

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