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

Wrapper around a block of memory, containing both the size and the address of the memory block. More...

#include <memory_block.hpp>

Public Member Functions

constexpr memory_block () noexcept
 Constructs a memory block pointing to null with 0 size.
 
constexpr memory_block (nullblock_t) noexcept
 Constructs a memory block pointing to null with 0 size. More...
 
constexpr memory_block (void *data, std::size_t size) noexcept
 Constructs a memory_block at the specified memory address, data, with the specified size size. More...
 
constexpr memory_block (const memory_block &other) noexcept=default
 Copy-constructs a memory_block by copying another memory_block. More...
 
constexpr memory_block (memory_block &&other) noexcept=default
 Move-constructs a memory_block by copying another memory_block. More...
 
memory_blockoperator= (const memory_block &other) noexcept=default
 Copy-assigns a memory_block from another memory_block. More...
 
memory_blockoperator= (memory_block &&other) noexcept=default
 Move-assigns a memory_block from another memory_block. More...
 
constexpr void * data () const noexcept
 Retrieves the pointer to the data. More...
 
constexpr void * start_address () const noexcept
 Retrieves the start address of this memory block. More...
 
constexpr void * end_address () const noexcept
 Retrieves the end address of this memory block. More...
 
constexpr std::size_t size () const noexcept
 Retrieves the size of a data. More...
 
bool contains (const void *ptr) const noexcept
 Evaluates whether ptr exists within this memory_block. More...
 
constexpr operator bool () const noexcept
 Contextually convertible to bool.
 
void swap (memory_block &other) noexcept
 Swaps this memory_block with other. More...
 

Detailed Description

Wrapper around a block of memory, containing both the size and the address of the memory block.

Definition at line 60 of file memory_block.hpp.

Constructor & Destructor Documentation

◆ memory_block() [1/4]

constexpr bit::memory::memory_block::memory_block ( nullblock_t  )
noexcept

Constructs a memory block pointing to null with 0 size.

◆ memory_block() [2/4]

constexpr bit::memory::memory_block::memory_block ( void *  data,
std::size_t  size 
)
noexcept

Constructs a memory_block at the specified memory address, data, with the specified size size.

Parameters
dataThe memory address to start the block
sizeThe size of the memory block

◆ memory_block() [3/4]

constexpr bit::memory::memory_block::memory_block ( const memory_block other)
defaultnoexcept

Copy-constructs a memory_block by copying another memory_block.

Parameters
otherthe other memory_block to copy

◆ memory_block() [4/4]

constexpr bit::memory::memory_block::memory_block ( memory_block &&  other)
defaultnoexcept

Move-constructs a memory_block by copying another memory_block.

Parameters
otherthe other memory_block to move

Member Function Documentation

◆ contains()

bool bit::memory::memory_block::contains ( const void *  ptr) const
noexcept

Evaluates whether ptr exists within this memory_block.

Parameters
ptrthe pointer to evaluate
Returns
true whether ptr

◆ data()

constexpr void* bit::memory::memory_block::data ( ) const
noexcept

Retrieves the pointer to the data.

Returns
the pointer to the data

◆ end_address()

constexpr void* bit::memory::memory_block::end_address ( ) const
noexcept

Retrieves the end address of this memory block.

Note
That the end address is 1 past the end of the memory block
Returns
the pointer to the end of the data block

◆ operator=() [1/2]

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

Copy-assigns a memory_block from another memory_block.

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

◆ operator=() [2/2]

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

Move-assigns a memory_block from another memory_block.

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

◆ size()

constexpr std::size_t bit::memory::memory_block::size ( ) const
noexcept

Retrieves the size of a data.

Returns
the size of the data

◆ start_address()

constexpr void* bit::memory::memory_block::start_address ( ) const
noexcept

Retrieves the start address of this memory block.

This is the same as data()

Returns
the pointer to the data block

◆ swap()

void bit::memory::memory_block::swap ( memory_block other)
noexcept

Swaps this memory_block with other.

Parameters
otherthe other entry to swap

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