bit::memory
Classes | Public Member Functions | Friends | List of all members
bit::memory::block_allocator_reference Class Referencefinal

A type erased view of allocators that satisfy the BlockAllocator concept. More...

#include <block_allocator_reference.hpp>

Public Member Functions

template<typename BlockAllocator , typename = std::enable_if_t<is_block_allocator<BlockAllocator>::value && !std::is_same<block_allocator_reference,BlockAllocator>::value>>
 block_allocator_reference (BlockAllocator &allocator) noexcept
 Constructs a block allocator by type erasing the underlying allocator. More...
 
 block_allocator_reference (block_allocator_reference &&other) noexcept=default
 Move-constructs a block_allocator from an existing one. More...
 
 block_allocator_reference (const block_allocator_reference &other) noexcept=default
 Copy-constructs a block_allocator from an existing one. More...
 
block_allocator_referenceoperator= (block_allocator_reference &&other) noexcept=default
 Move-assigns a block_allocator from an existing one. More...
 
block_allocator_referenceoperator= (const block_allocator_reference &other) noexcept=default
 Copy-assigns a block_allocator from an existing one. More...
 
owner< memory_blockallocate_block ()
 Allocates a block from the underlying block allocator. More...
 
void deallocate_block (owner< memory_block > block)
 Deallocates a block from the underlying block allocatore. More...
 
allocator_info info () const noexcept
 Gets information about this allocator. More...
 
std::size_t next_block_size () const noexcept
 Gets the next available block size for this allocator. More...
 

Friends

template<typename >
block_allocator_reference make_stateless_block_allocator_reference () noexcept
 Makes a block_allocator_reference that refers to a stateless block allocator. More...
 

Detailed Description

A type erased view of allocators that satisfy the BlockAllocator concept.

This view is non-owning, and thus does not participate in the lifetime of a given allocator.

Satisfies
BlockAllocator

Definition at line 65 of file block_allocator_reference.hpp.

Constructor & Destructor Documentation

◆ block_allocator_reference() [1/3]

template<typename BlockAllocator , typename = std::enable_if_t<is_block_allocator<BlockAllocator>::value && !std::is_same<block_allocator_reference,BlockAllocator>::value>>
bit::memory::block_allocator_reference::block_allocator_reference ( BlockAllocator &  allocator)
noexcept

Constructs a block allocator by type erasing the underlying allocator.

Parameters
allocatorthe block allocator to type-erase

◆ block_allocator_reference() [2/3]

bit::memory::block_allocator_reference::block_allocator_reference ( block_allocator_reference &&  other)
defaultnoexcept

Move-constructs a block_allocator from an existing one.

Parameters
otherthe other allocator to move

◆ block_allocator_reference() [3/3]

bit::memory::block_allocator_reference::block_allocator_reference ( const block_allocator_reference other)
defaultnoexcept

Copy-constructs a block_allocator from an existing one.

Parameters
otherthe other allocator to copy

Member Function Documentation

◆ allocate_block()

owner<memory_block> bit::memory::block_allocator_reference::allocate_block ( )

Allocates a block from the underlying block allocator.

Returns
the allocated memory block

◆ deallocate_block()

void bit::memory::block_allocator_reference::deallocate_block ( owner< memory_block block)

Deallocates a block from the underlying block allocatore.

Parameters
blockthe block to deallocate

◆ info()

allocator_info bit::memory::block_allocator_reference::info ( ) const
noexcept

Gets information about this allocator.

Returns
the allocator information

◆ next_block_size()

std::size_t bit::memory::block_allocator_reference::next_block_size ( ) const
noexcept

Gets the next available block size for this allocator.

Returns
the next block size

◆ operator=() [1/2]

block_allocator_reference& bit::memory::block_allocator_reference::operator= ( block_allocator_reference &&  other)
defaultnoexcept

Move-assigns a block_allocator from an existing one.

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

◆ operator=() [2/2]

block_allocator_reference& bit::memory::block_allocator_reference::operator= ( const block_allocator_reference other)
defaultnoexcept

Copy-assigns a block_allocator from an existing one.

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

Friends And Related Function Documentation

◆ make_stateless_block_allocator_reference

template<typename >
block_allocator_reference make_stateless_block_allocator_reference ( )
friend

Makes a block_allocator_reference that refers to a stateless block allocator.

This creates a reference to any stateless block allocator, even though different instances may have different underlying addresses.

Template Parameters
StatelessBlockAllocatorthe type of a stateless block allocator

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