microfmt
Zero-allocation C++ formatting for constrained environments
Loading...
Searching...
No Matches
Public Member Functions | List of all members
microfmt::remote_ref< T > Class Template Reference

Lazily-loaded reference to a trivially-copyable remote object. More...

#include <address_space.hpp>

Public Member Functions

constexpr remote_ref (uintptr_t addr, address_space_ref space, span< std::byte > scratch RELOCO_LIFETIMEBOUND RELOCO_LIFETIME_CAPTURE_BY_THIS) noexcept
 Constructs a remote object reference.
 
template<size_t N>
constexpr remote_ref (uintptr_t addr, address_space_ref space, std::byte(&scratch)[N]) noexcept
 Constructs a remote object reference over a fixed C array.
 
constexpr uintptr_t address () const noexcept
 Returns the remote object address.
 
constexpr bool is_null () const noexcept
 Reports whether the reference points to address zero.
 
RELOCO_BEGIN_UNSAFE_CODE expected< T *, remote_load_error > load () const noexcept
 Loads the object into the scratch buffer.
 

Detailed Description

template<typename T>
class microfmt::remote_ref< T >

Lazily-loaded reference to a trivially-copyable remote object.

Template Parameters
TObject type loaded into a caller-supplied scratch buffer.

Constructor & Destructor Documentation

◆ remote_ref() [1/2]

template<typename T >
constexpr microfmt::remote_ref< T >::remote_ref ( uintptr_t  addr,
address_space_ref  space,
span< std::byte > scratch RELOCO_LIFETIMEBOUND  RELOCO_LIFETIME_CAPTURE_BY_THIS 
)
inlineconstexprnoexcept

Constructs a remote object reference.

Parameters
addrAbsolute address of the object.
spaceAddress space the object lives in.
scratchReusable, properly-aligned scratch buffer (>= sizeof(T)).

◆ remote_ref() [2/2]

template<typename T >
template<size_t N>
constexpr microfmt::remote_ref< T >::remote_ref ( uintptr_t  addr,
address_space_ref  space,
std::byte(&)  scratch[N] 
)
inlineconstexprnoexcept

Constructs a remote object reference over a fixed C array.

Template Parameters
NSize of the scratch array.
Parameters
addrAbsolute address of the object.
spaceAddress space the object lives in.
scratchReusable, properly-aligned scratch buffer.

Member Function Documentation

◆ address()

template<typename T >
constexpr uintptr_t microfmt::remote_ref< T >::address ( ) const
inlineconstexprnoexcept

Returns the remote object address.

Returns
Absolute address, or 0 when null.

◆ is_null()

template<typename T >
constexpr bool microfmt::remote_ref< T >::is_null ( ) const
inlineconstexprnoexcept

Reports whether the reference points to address zero.

Returns
true when the reference is null.

◆ load()

template<typename T >
RELOCO_BEGIN_UNSAFE_CODE expected< T *, remote_load_error > microfmt::remote_ref< T >::load ( ) const
inlinenoexcept

Loads the object into the scratch buffer.

Returns
A pointer into the scratch buffer, or a precise loading error.

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