bit::memory
Public Member Functions | Private Member Functions | List of all members
bit::memory::aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier > Class Template Reference

An allocator that allocates over-aligned memory. More...

#include <aligned_block_allocator.hpp>

Inheritance diagram for bit::memory::aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier >:
bit::memory::ebo_storage< GrowthMultiplier > bit::memory::dynamic_size_type< 0, DefaultBlockSize > bit::memory::dynamic_size_type< 1, BlockAlign >

Public Member Functions

 aligned_block_allocator ()=default
 Constructs a aligned_block_allocator that will distribute blocks of the specified size.
 
template<std::size_t USize = DefaultBlockSize, std::size_t UAlign = BlockAlign, typename = std::enable_if_t<(USize!=dynamic_block_size) && (UAlign!=dynamic_block_alignment)>>
 aligned_block_allocator (GrowthMultiplier growth)
 Constructs an aligned_block_allocator with the specified growth policy. More...
 
template<std::size_t USize = DefaultBlockSize, typename = std::enable_if_t<USize==dynamic_block_size>>
 aligned_block_allocator (block_size_t block_size, GrowthMultiplier growth=GrowthMultiplier{})
 Constructs an aligned_block_allocator with the specified growth policy. More...
 
template<std::size_t UAlign = BlockAlign, typename = std::enable_if_t<UAlign==dynamic_block_alignment>>
 aligned_block_allocator (block_alignment_t block_alignment, GrowthMultiplier growth=GrowthMultiplier{})
 Constructs an aligned_block_allocator with the specified growth policy. More...
 
template<std::size_t USize = DefaultBlockSize, std::size_t UAlign = BlockAlign, typename = std::enable_if_t<(USize==dynamic_block_size) && (UAlign==dynamic_block_alignment)>>
 aligned_block_allocator (block_size_t block_size, block_alignment_t block_alignment, GrowthMultiplier growth=GrowthMultiplier{})
 Constructs an aligned_block_allocator with the specified growth policy. More...
 
 aligned_block_allocator (aligned_block_allocator &&other)=default
 Move-constructs an aligned_block_allocator from another allocator. More...
 
 aligned_block_allocator (const aligned_block_allocator &other)=default
 Copy-constructs an aligned_block_allocator from another allocator. More...
 
aligned_block_allocatoroperator= (aligned_block_allocator &&other)=default
 Move-assigns an aligned_block_allocator from another allocator. More...
 
aligned_block_allocatoroperator= (const aligned_block_allocator &other)=default
 Copy-assigns an aligned_block_allocator from another allocator. More...
 
owner< memory_blockallocate_block () noexcept
 Allocates a memory_block of size block_size with alignment Align. 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...
 

Private Member Functions

constexpr std::size_t value () const noexcept
 Retrieves the value. More...
 
constexpr std::size_t value () const noexcept
 Retrieves the value. More...
 

Detailed Description

template<std::size_t DefaultBlockSize, std::size_t BlockAlign, typename GrowthMultiplier = no_growth_multiplier>
class bit::memory::aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier >

An allocator that allocates over-aligned memory.

Note
This allocator should only be used for over-aligned memory blocks where required. It does not make sense to be used if the required alignment of each block is less than or equal to alignof(std::max_align_t) – as this fundamental alignment is required of both the 'new_block_allocator' and 'malloc_block_allocator' without requiring any additional overhead
Template Parameters
SizeThe size of the block
AlignThe alignment of block
Satisfies
BlockAllocator
Satisfies
Stateless

Definition at line 81 of file aligned_block_allocator.hpp.

Constructor & Destructor Documentation

◆ aligned_block_allocator() [1/6]

template<std::size_t DefaultBlockSize, std::size_t BlockAlign, typename GrowthMultiplier = no_growth_multiplier>
template<std::size_t USize = DefaultBlockSize, std::size_t UAlign = BlockAlign, typename = std::enable_if_t<(USize!=dynamic_block_size) && (UAlign!=dynamic_block_alignment)>>
bit::memory::aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier >::aligned_block_allocator ( GrowthMultiplier  growth)
explicit

Constructs an aligned_block_allocator with the specified growth policy.

Parameters
growththe growth multiplier policy

◆ aligned_block_allocator() [2/6]

template<std::size_t DefaultBlockSize, std::size_t BlockAlign, typename GrowthMultiplier = no_growth_multiplier>
template<std::size_t USize = DefaultBlockSize, typename = std::enable_if_t<USize==dynamic_block_size>>
bit::memory::aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier >::aligned_block_allocator ( block_size_t  block_size,
GrowthMultiplier  growth = GrowthMultiplier{} 
)
explicit

Constructs an aligned_block_allocator with the specified growth policy.

Parameters
block_sizethe default block size
growththe growth multiplier policy

◆ aligned_block_allocator() [3/6]

template<std::size_t DefaultBlockSize, std::size_t BlockAlign, typename GrowthMultiplier = no_growth_multiplier>
template<std::size_t UAlign = BlockAlign, typename = std::enable_if_t<UAlign==dynamic_block_alignment>>
bit::memory::aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier >::aligned_block_allocator ( block_alignment_t  block_alignment,
GrowthMultiplier  growth = GrowthMultiplier{} 
)
explicit

Constructs an aligned_block_allocator with the specified growth policy.

Parameters
block_alignmentthe default block alignment
growththe growth multiplier policy

◆ aligned_block_allocator() [4/6]

template<std::size_t DefaultBlockSize, std::size_t BlockAlign, typename GrowthMultiplier = no_growth_multiplier>
template<std::size_t USize = DefaultBlockSize, std::size_t UAlign = BlockAlign, typename = std::enable_if_t<(USize==dynamic_block_size) && (UAlign==dynamic_block_alignment)>>
bit::memory::aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier >::aligned_block_allocator ( block_size_t  block_size,
block_alignment_t  block_alignment,
GrowthMultiplier  growth = GrowthMultiplier{} 
)

Constructs an aligned_block_allocator with the specified growth policy.

Parameters
block_sizethe default block size
block_alignmentthe default block alignment
growththe growth multiplier policy

◆ aligned_block_allocator() [5/6]

template<std::size_t DefaultBlockSize, std::size_t BlockAlign, typename GrowthMultiplier = no_growth_multiplier>
bit::memory::aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier >::aligned_block_allocator ( aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier > &&  other)
default

Move-constructs an aligned_block_allocator from another allocator.

Parameters
otherthe other aligned_block_allocator to move

◆ aligned_block_allocator() [6/6]

template<std::size_t DefaultBlockSize, std::size_t BlockAlign, typename GrowthMultiplier = no_growth_multiplier>
bit::memory::aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier >::aligned_block_allocator ( const aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier > &  other)
default

Copy-constructs an aligned_block_allocator from another allocator.

Parameters
otherthe other aligned_block_allocator to copy

Member Function Documentation

◆ allocate_block()

template<std::size_t DefaultBlockSize, std::size_t BlockAlign, typename GrowthMultiplier = no_growth_multiplier>
owner<memory_block> bit::memory::aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier >::allocate_block ( )
noexcept

Allocates a memory_block of size block_size with alignment Align.

Returns
a newly allocated memory_block

◆ deallocate_block()

template<std::size_t DefaultBlockSize, std::size_t BlockAlign, typename GrowthMultiplier = no_growth_multiplier>
void bit::memory::aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier >::deallocate_block ( owner< memory_block block)
noexcept

Deallocates a given memory_block.

Parameters
blockthe block to deallocate

◆ info()

template<std::size_t DefaultBlockSize, std::size_t BlockAlign, typename GrowthMultiplier = no_growth_multiplier>
allocator_info bit::memory::aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier >::info ( ) const
noexcept

Gets the info about this allocator.

This defaults to 'aligned_block_allocator'. Use a named_aligned_block_allocator to override this

Returns
the info for this allocator

◆ next_block_size()

template<std::size_t DefaultBlockSize, std::size_t BlockAlign, typename GrowthMultiplier = no_growth_multiplier>
std::size_t bit::memory::aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier >::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 DefaultBlockSize, std::size_t BlockAlign, typename GrowthMultiplier = no_growth_multiplier>
aligned_block_allocator& bit::memory::aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier >::operator= ( aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier > &&  other)
default

Move-assigns an aligned_block_allocator from another allocator.

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

◆ operator=() [2/2]

template<std::size_t DefaultBlockSize, std::size_t BlockAlign, typename GrowthMultiplier = no_growth_multiplier>
aligned_block_allocator& bit::memory::aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier >::operator= ( const aligned_block_allocator< DefaultBlockSize, BlockAlign, GrowthMultiplier > &  other)
default

Copy-assigns an aligned_block_allocator from another allocator.

Parameters
otherthe other aligned_block_allocator to copy
Returns
reference to (*this)

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