Class for handling memory addresses as integer values. More...
#include <eagine/memory/address.hpp>
Public Types | |
using | pointer = std::conditional_t< IsConst, const void *, void * > |
The associated untyped pointer type. | |
using | byte_pointer = std::conditional_t< IsConst, const byte *, byte * > |
The associated byte pointer type. | |
Public Member Functions | |
constexpr | basic_address () noexcept=default |
Default constructor. | |
constexpr | basic_address (basic_address &&) noexcept=default |
Move constructor. | |
constexpr auto | operator= (basic_address &&) noexcept -> basic_address &=default |
Move assignment operator. | |
constexpr | basic_address (const basic_address &) noexcept=default |
Copy constructor. | |
constexpr auto | operator= (const basic_address &) noexcept -> basic_address &=default |
Copy assignment operator. | |
constexpr | basic_address (std::nullptr_t) noexcept |
Construction from nullptr. | |
constexpr | basic_address (std::intptr_t addr) noexcept |
Construction from signed integer type. | |
constexpr | basic_address (pointer addr) noexcept |
Construction from untyped pointer type. | |
constexpr auto | is_null () const noexcept |
Indicates if the stored address is null. | |
constexpr | operator bool () const noexcept |
Indicates if the stored address is not null. More... | |
constexpr auto | ptr () const noexcept |
Returns the byte pointer for this address. More... | |
constexpr auto | get () const noexcept |
Returns the untyped pointer for this address. More... | |
constexpr | operator pointer () const noexcept |
Explicit cast to the untyped pointer for this address. More... | |
template<typename T , typename = std::enable_if_t<!std::is_void_v<T> && (std::is_const_v<T> || !IsConst)>> | |
constexpr | operator T* () const noexcept |
Explicit cast to a typed pointer for this address. More... | |
constexpr auto | value () const noexcept |
Returns this address as an signed integer. More... | |
constexpr auto | misalignment (span_size_t alignment) const noexcept |
Returns the misalignment of this address to the specified alignment. More... | |
constexpr auto | is_aligned_to (span_size_t alignment) const noexcept |
Indicates if this address is aligned to the specified alignment. More... | |
template<typename T > | |
constexpr auto | is_aligned_as (type_identity< T > tid={}) const noexcept |
Indicates if this address is aligned to the alignment or type T. More... | |
Friends | |
constexpr friend auto | operator== (basic_address a, basic_address b) noexcept |
Equality comparison. | |
constexpr friend auto | operator!= (basic_address a, basic_address b) noexcept |
Non-equality comparison. | |
constexpr friend auto | operator< (basic_address a, basic_address b) noexcept |
Less-than comparison. | |
constexpr friend auto | operator<= (basic_address a, basic_address b) noexcept |
Less-equal comparison. | |
constexpr friend auto | operator> (basic_address a, basic_address b) noexcept |
Greater-than comparison. | |
constexpr friend auto | operator>= (basic_address a, basic_address b) noexcept |
Greater-equal comparison. | |
constexpr friend auto | operator- (basic_address a, basic_address b) noexcept -> std::ptrdiff_t |
Byte difference between two addresses. | |
constexpr friend auto | operator+ (basic_address a, std::ptrdiff_t o) noexcept -> basic_address |
Byte offset addition. | |
constexpr friend auto | operator- (basic_address a, std::ptrdiff_t o) noexcept -> basic_address |
Byte offset subtraction. | |
Class for handling memory addresses as integer values.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Indicates if this address is aligned to the alignment or type T.
|
inlineconstexprnoexcept |
Indicates if this address is aligned to the specified alignment.
|
inlineconstexprnoexcept |
Returns the misalignment of this address to the specified alignment.
|
inlineexplicitconstexprnoexcept |
Indicates if the stored address is not null.
|
inlineexplicitconstexprnoexcept |
Explicit cast to the untyped pointer for this address.
|
inlineexplicitconstexprnoexcept |
Explicit cast to a typed pointer for this address.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Returns this address as an signed integer.
Referenced by eagine::memory::align_down(), eagine::memory::basic_address< IsConst >::is_aligned_to(), and eagine::memory::basic_address< IsConst >::misalignment().