bit::memory
Public Types | Public Member Functions | List of all members
bit::memory::aligned_offset_allocator Class Reference

This stateless allocator performs all of its allocation calls using aligned memory invocations aligned to an offset. More...

#include <aligned_offset_allocator.hpp>

Public Types

using default_alignment = std::integral_constant< std::size_t, 1 >
 

Public Member Functions

 aligned_offset_allocator ()=default
 Default-constructs a aligned_offset_allocator.
 
 aligned_offset_allocator (aligned_offset_allocator &&other) noexcept=default
 Move-constructs a aligned_offset_allocator from another allocator. More...
 
 aligned_offset_allocator (const aligned_offset_allocator &other) noexcept=default
 Copy-constructs a aligned_offset_allocator from another allocator. More...
 
aligned_offset_allocatoroperator= (aligned_offset_allocator &&other) noexcept=default
 Move-assigns an aligned_offset_allocator from another allocator. More...
 
aligned_offset_allocatoroperator= (const aligned_offset_allocator &other) noexcept=default
 Copy-assigns an aligned_offset_allocator from another allocator. More...
 
owner< void * > try_allocate (std::size_t size, std::size_t align, std::size_t offset=0) noexcept
 Allocates aligned memory of size size, with alignment to a boundary of at least align, aligned to an offset. More...
 
void deallocate (owner< void *> p, std::size_t size)
 Deallocates a pointer p with the allocation size of size. More...
 
allocator_info info () const noexcept
 Gets the info about this allocator. More...
 

Detailed Description

This stateless allocator performs all of its allocation calls using aligned memory invocations aligned to an offset.

Satisfies
ExtendedAllocator
Satisfies
Stateless

Definition at line 58 of file aligned_offset_allocator.hpp.

Constructor & Destructor Documentation

◆ aligned_offset_allocator() [1/2]

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

Move-constructs a aligned_offset_allocator from another allocator.

Parameters
otherthe other aligned_offset_allocator to move

◆ aligned_offset_allocator() [2/2]

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

Copy-constructs a aligned_offset_allocator from another allocator.

Parameters
otherthe other aligned_offset_allocator to copy

Member Function Documentation

◆ deallocate()

void bit::memory::aligned_offset_allocator::deallocate ( owner< void *>  p,
std::size_t  size 
)

Deallocates a pointer p with the allocation size of size.

Parameters
pthe pointer to deallocate
sizethe size to deallocate

◆ info()

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

Gets the info about this allocator.

This defaults to 'aligned_offset_allocator'. Use a named_aligned_offset_allocator to override this

Returns
the info for this allocator

◆ operator=() [1/2]

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

Move-assigns an aligned_offset_allocator from another allocator.

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

◆ operator=() [2/2]

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

Copy-assigns an aligned_offset_allocator from another allocator.

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

◆ try_allocate()

owner<void*> bit::memory::aligned_offset_allocator::try_allocate ( std::size_t  size,
std::size_t  align,
std::size_t  offset = 0 
)
noexcept

Allocates aligned memory of size size, with alignment to a boundary of at least align, aligned to an offset.

Parameters
sizethe size of this allocation
alignthe requested alignment
offsetthe offset to align to
Returns
the allocated pointer, or nullptr on failure

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