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

External context holder capturing container state and traversal/formatting logic. More...

#include <remote_container.hpp>

Public Member Functions

constexpr container_context (IteratorState initial_state, FormatterFn formatter) noexcept
 Stores container traversal state and its formatting callback.
 
constexpr IteratorState & state () &noexcept RELOCO_LIFETIMEBOUND
 Returns the mutable traversal state.
 
constexpr const IteratorState & state () const &noexcept RELOCO_LIFETIMEBOUND
 Returns the traversal state.
 
constexpr const IteratorState & state () const &&=delete
 

Static Public Member Functions

static bool format_thunk (void *raw_ctx, address_space_ref space, span< std::byte > scratch, const sink &out, const container_options &opts) noexcept
 Invokes the stored formatter through the type-erased view API.
 

Detailed Description

template<typename IteratorState, typename FormatterFn>
class microfmt::container_context< IteratorState, FormatterFn >

External context holder capturing container state and traversal/formatting logic.

Created via make_container_context and stored safely in the caller's stack frame.

Template Parameters
IteratorStateState retained while traversing the container.
FormatterFnCallable used to format the container.

Constructor & Destructor Documentation

◆ container_context()

template<typename IteratorState , typename FormatterFn >
constexpr microfmt::container_context< IteratorState, FormatterFn >::container_context ( IteratorState  initial_state,
FormatterFn  formatter 
)
inlineconstexprnoexcept

Stores container traversal state and its formatting callback.

Parameters
initial_stateInitial state used by formatter.
formatterCallable that renders the container.

Member Function Documentation

◆ format_thunk()

template<typename IteratorState , typename FormatterFn >
static bool microfmt::container_context< IteratorState, FormatterFn >::format_thunk ( void *  raw_ctx,
address_space_ref  space,
span< std::byte >  scratch,
const sink &  out,
const container_options &  opts 
)
inlinestaticnoexcept

Invokes the stored formatter through the type-erased view API.

Parameters
raw_ctxPointer to this context.
spaceAddress space containing the container.
scratchReusable scratch storage for remote reads.
outOutput destination.
optsRendering options selected by the view.
Returns
The result reported by the stored formatter.

◆ state() [1/3]

template<typename IteratorState , typename FormatterFn >
constexpr IteratorState & microfmt::container_context< IteratorState, FormatterFn >::state ( ) &
inlineconstexprnoexcept

Returns the mutable traversal state.

Returns
Reference to the stored state.

◆ state() [2/3]

template<typename IteratorState , typename FormatterFn >
constexpr const IteratorState & microfmt::container_context< IteratorState, FormatterFn >::state ( ) const &&
constexprdelete

◆ state() [3/3]

template<typename IteratorState , typename FormatterFn >
constexpr const IteratorState & microfmt::container_context< IteratorState, FormatterFn >::state ( ) const &
inlineconstexprnoexcept

Returns the traversal state.

Returns
Const reference to the stored state.

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