fmt::formatter

A formatter for objects of type T.

Synopsis

Declared in <fmt/base.h>

template<
    typename T,
    typename Char = char,
    typename Enable = void>
struct formatter;

Member Functions

NameDescription
formatter [constructor] [deleted]Deleted to indicate that this formatter is disabled by default; a specialization must define a usable default constructor to enable formatting for a given T.

Specializations

NameDescription
formatter</* implementation-defined */> A formatter specialization for detail::bigint, used to print its value as hexadecimal bigits for debugging.
formatter<bytes> Formats a bytes view using the string presentation rules.
formatter<std::error_code> Formats std::error_code as category:value, or as its message() when the s type specifier is given.
formatter<__exception_ptr::exception_ptr> Formats std::exception_ptr by rethrowing and formatting the exception it holds, or as none when empty.
formatter<std::source_location> Formats std::source_location as file:line:column: function.
formatter<std::type_info> Formats std::type_info as its demangled type name.
formatter<group_digits_view<T>> Formats a group_digits_view by writing its integer value with ',' as a thousands separator.
formatter<T, char> Formats any type derived from std::exception as its what() message, optionally prefixed with its demangled type name when the t specifier is given.
formatter<std::atomic_flag, Char> Formats std::atomic_flag the same way as the bool returned by test.
formatter<std::byte, Char> Formats std::byte the same way as the unsigned char it holds.
formatter<day, Char> Formats a fmt::day.
formatter</* implementation-defined */, Char> Specializes formatter for detail::float128, an extended-precision floating-point type, reusing the native floating-point formatting logic.
formatter<std::thread::id, Char> Formats std::thread::id the same way as its operator<< overload, via basic_ostream_formatter.
formatter<long, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter<std::monostate, Char> Formats std::monostate as the literal string monostate.
formatter<month, Char> Formats a fmt::month.
formatter<std::nullptr_t, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter<std::filesystem::path, Char> Formats std::filesystem::path, honoring the ? debug-quoting and g generic-path-format specifiers.
formatter<short, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter<signed char, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter<tm, Char> Formats a std::tm.
formatter<unsigned char, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter<unsigned long, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter<unsigned short, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter<weekday, Char> Formats a fmt::weekday.
formatter<year, Char> Formats a fmt::year.
formatter<year_month_day, Char> Formats a fmt::year_month_day.
formatter</* implementation-defined */, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter<Char*, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter<void*, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter<BitRef, Char> Formats a bit-reference proxy (e.g. std::vector<bool>::reference or std::bitset<N>::reference) the same way as the bool it refers to.
formatter<R, Char> Formats a range R as a bracketed, separator-delimited sequence of its elements, for range kinds other than map, string, and debug string.
formatter<R, Char> Formats a map-like range R as a {key: value, ...} sequence of its key-value pairs.
formatter<R, Char> Formats a range R of characters as a string, quoting and escaping it when R's range format kind is debug_string.
formatter<T, Char> A formatter specialization for natively supported types.
formatter<T, Char> Formats a container adaptor T (like std::stack) as its underlying container.
formatter<Tuple, Char> Formats a tuple-like type as a parenthesized, separator-delimited sequence of its elements.
formatter<Variant, Char> Formats a variant-like type as variant(alternative), or as valueless by exception if it holds no value.
formatter<std::atomic<T>, Char> Formats std::atomic<T> the same way as the T value it holds, loading it before formatting.
formatter<std::bitset<N>, Char> Formats std::bitset<N> as a string of '0'/'1' characters, most significant bit first.
formatter<std::complex<T>, Char> Formats std::complex<T> as real+imagi (or real-imagi), applying the parsed specs to both the real and imaginary parts.
formatter<local_time<Duration>, Char> Formats a std::chrono::local_time, which has an unspecified time zone.
formatter<nested_view<T, Char>, Char> Formats a nested_view by delegating to its stored formatter.
formatter<std::optional<T>, Char> Formats std::optional<T> as optional(value), or as none when it is empty.
formatter<std::reference_wrapper<T>, Char> Formats std::reference_wrapper<T> the same way as the referenced T.
formatter</* implementation-defined */, Char> A formatter for values wrapped with fmt::streamed, which formats the wrapped value via its ostream operator<<.
formatter</* implementation-defined */, Char> Formatter for a value wrapped by fmt::styled, applying the wrapped text style around the underlying formatter's output.
formatter<sys_time<Duration>, Char> Formats a std::chrono::sys_time.
formatter<tuple_join_view<Tuple, Char>, Char> Formats a tuple_join_view, writing each tuple element with its own formatter, separated by tuple_join_view::sep.
formatter</* implementation-defined */, Char> Formats a signed bit-precise integer (_BitInt(N)) the same way as long long, by first converting it.
formatter<std::unexpected<E>, Char> Formats std::unexpected<E> as unexpected(error).
formatter<utc_time<Duration>, Char> Formats a std::chrono::utc_time.
formatter<Char[], Char> Specializes formatter for character arrays (string literals), formatting them as basic_string_view<Char>.
formatter<std::basic_string<Char, Traits, Allocator>, Char> Specializes formatter for std::basic_string, formatting it as basic_string_view<Char>.
formatter<std::chrono::duration<Rep, Period>, Char> Formats a std::chrono::duration.
formatter<std::expected<T, E>, Char> Formats std::expected<T, E> as expected(value) when it holds a value, or as unexpected(error) when it holds an error.
formatter<join_view<It, Sentinel, Char>, Char> Formats a join_view, writing each element with its own formatter, separated by join_view::sep.
formatter<T, Char, void_t</* implementation-defined */>> Specializes formatter for types T that have an associated format_as overload, by formatting the result of format_as(value) instead of T directly.

Derived Classes

NameDescription
basic_ostream_formatter Formats an object of type T that has an overloaded ostream operator<<.
formatter<void*, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter<long, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter<unsigned short, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter<std::reference_wrapper<T>, Char> Formats std::reference_wrapper<T> the same way as the referenced T.
formatter<short, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter<T, Char> Formats a container adaptor T (like std::stack) as its underlying container.
formatter<group_digits_view<T>> Formats a group_digits_view by writing its integer value with ',' as a thousands separator.
formatter<std::byte, Char> Formats std::byte the same way as the unsigned char it holds.
formatter<T, Char, void_t</* implementation-defined */>> Specializes formatter for types T that have an associated format_as overload, by formatting the result of format_as(value) instead of T directly.
formatter<Char[], Char> Specializes formatter for character arrays (string literals), formatting them as basic_string_view<Char>.
formatter<std::basic_string<Char, Traits, Allocator>, Char> Specializes formatter for std::basic_string, formatting it as basic_string_view<Char>.
formatter<BitRef, Char> Formats a bit-reference proxy (e.g. std::vector<bool>::reference or std::bitset<N>::reference) the same way as the bool it refers to.
formatter<std::atomic_flag, Char> Formats std::atomic_flag the same way as the bool returned by test.
formatter</* implementation-defined */, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter<unsigned char, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter</* implementation-defined */, Char> Formats a signed bit-precise integer (_BitInt(N)) the same way as long long, by first converting it.
formatter<std::nullptr_t, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter</* implementation-defined */, Char> Formatter for a value wrapped by fmt::styled, applying the wrapped text style around the underlying formatter's output.
formatter<utc_time<Duration>, Char> Formats a std::chrono::utc_time.
formatter<signed char, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter<unsigned long, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter<__exception_ptr::exception_ptr> Formats std::exception_ptr by rethrowing and formatting the exception it holds, or as none when empty.
formatter<Char*, Char> Specializes formatter<Type, Char> to format Type values the same way as Base, by delegating to formatter<Base, Char>.
formatter<std::atomic<T>, Char> Formats std::atomic<T> the same way as the T value it holds, loading it before formatting.