microfmt
Zero-allocation C++ formatting for constrained environments
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
microfmt::detail::element_formatter< T > Struct Template Reference

Drop-in replacement for a formatter<T> underlying_formatter; member used by container/wrapper formatters (reloco.hpp, tuple.hpp, map_view.hpp, filter_view.hpp, ranges.hpp, variant.hpp, ...) to format their elements/keys/values. More...

#include <microfmt.hpp>

Classes

struct  no_formatter_stub
 

Public Types

using DecayedT = std::decay_t< T >
 

Public Member Functions

constexpr void parse (format_parse_context &ctx) noexcept
 
void format (const T &value, const sink &out) const noexcept
 

Public Attributes

std::conditional_t< has_formatter_v< DecayedT >, formatter< DecayedT >, no_formatter_stub > underlying {}
 

Detailed Description

template<typename T>
struct microfmt::detail::element_formatter< T >

Drop-in replacement for a formatter<T> underlying_formatter; member used by container/wrapper formatters (reloco.hpp, tuple.hpp, map_view.hpp, filter_view.hpp, ranges.hpp, variant.hpp, ...) to format their elements/keys/values.

Exposes the same parse(format_parse_context&) / format(const T&, const sink&) const interface as formatter<T> itself, but implements the same formatter<T> -> reloco::Display<T> -> reloco::Debug<T> priority chain as format_type_thunk above, instead of requiring a formatter<T> specialization unconditionally. This lets element types that only have a reloco::Display<T>/reloco::Debug<T> (and no formatter<T>) be nested inside containers/wrappers.

Display<T>/Debug<T> take no format spec (mirroring Rust), so parse simply discards the spec on those two paths, exactly as format_type_thunk does for a top-level {} placeholder.

Member Typedef Documentation

◆ DecayedT

template<typename T >
using microfmt::detail::element_formatter< T >::DecayedT = std::decay_t<T>

Member Function Documentation

◆ format()

template<typename T >
void microfmt::detail::element_formatter< T >::format ( const T &  value,
const sink &  out 
) const
inlinenoexcept

◆ parse()

template<typename T >
constexpr void microfmt::detail::element_formatter< T >::parse ( format_parse_context &  ctx)
inlineconstexprnoexcept

Member Data Documentation

◆ underlying

template<typename T >
std::conditional_t<has_formatter_v<DecayedT>, formatter<DecayedT>, no_formatter_stub> microfmt::detail::element_formatter< T >::underlying {}

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