Namespaces

Name

Description

fmt

Top‐level namespace for the {fmt} formatting library, wrapping all public API in the inline namespace v12 used to version the library's ABI.

Macros

Name

Description

FMT_STATIC_FORMAT

Formats arguments according to the format string fmt_str and produces a string of the exact required size at compile time. Both the format string and the arguments must be compile‐time expressions.

fmt namespace

Top‐level namespace for the {fmt} formatting library, wrapping all public API in the inline namespace v12 used to version the library's ABI.

Namespaces

Name

Description

enums

Contains format_as overloads that make enum types formattable by converting them to their underlying type.

safe_duration_cast

Helpers for converting between std::chrono::duration types without undefined behavior or erroneous results due to overflow.

Types

Name

Description

basic_appender

An output iterator that appends to a buffer. It is used instead of back_insert_iterator to reduce symbol sizes and avoid the <iterator> dependency.

basic_cstring_view

A reference to a null‐terminated string. It can be constructed from a C string or std::string.

basic_format_arg

A formatting argument. Context is a template parameter for the compiled API where output can be unbuffered.

basic_format_args

A view of a collection of formatting arguments. To avoid lifetime issues it should only be used as a parameter type in type‐erased functions such as vformat:

basic_fstring

A Char counterpart of fstring. Use basic_format_string in the public API to prevent type deduction.

basic_memory_buffer

A dynamically growing memory buffer for trivially copyable/constructible types with the first SIZE elements stored in the object itself. Most commonly used via the memory_buffer alias for char.

basic_ostream_formatter

Formats an object of type T that has an overloaded ostream operator<<.

basic_printf_context

The formatting context used to evaluate printf‐style format strings.

basic_specs

Basic format specifiers for built‐in and string types.

basic_string_view

An implementation of std::basic_string_view for pre‐C++17 providing a subset of the API. fmt::basic_string_view is used in the public API even if std::basic_string_view is available to prevent issues when a library is compiled with a different ‐std option than the client code (which is not recommended).

buffered_file

A buffered file.

bytes

A view over a string_view that formats its contents as raw bytes rather than as text.

compiled_string

A compile‐time string which is compiled into fast formatting code.

conjunction

Logical AND of a list of traits, each exposing a value bool constant, short‐circuiting like std::conjunction.

context

A formatting context.

dynamic_format_arg_store

A dynamic list of formatting arguments with storage.

file

A file. A closed file is represented by a file object with descriptor ‐1. Methods that are not declared with noexcept may throw fmt::system_error in case of failure.

format_error

An error reported from a formatting function.

format_facet

A locale facet that formats values in UTF‐8. It is parameterized on the locale to avoid the heavy <locale> include.

format_int

A fast integer formatter.

format_specs

Format specifiers for built‐in and string types.

format_to_n_result

The result of format_to_n.

format_to_result

The result of format_to writing into a fixed‐size character array.

formatter

A formatter for objects of type T.

fstring

A compile‐time format string. Use format_string in the public API to prevent type deduction.

generic_context

The format context implementation used for output iterators other than appender, type‐erasing the output iterator and character types.

group_digits_view

A view holding an integer value to be formatted with digit grouping.

is_compiled_string

A trait that detects whether S is a compile‐time string produced by FMT_COMPILE, i.e. derives from compiled_string.

is_container_adaptor

Specifies if T is a container adaptor (like std::stack) that should be formatted as the underlying container.

is_contiguous

Detects whether T stores its elements contiguously in memory.

is_range

Detects whether T is a range that should be formatted as a range, i.e. it has begin/`end` but is not optional‐like or string‐like.

is_tuple_formattable

Detects whether every element of tuple‐like type T is formattable with character type C.

is_tuple_like

Detects whether T is a tuple‐like type (supports std::tuple_size) that is not also a range.

is_variant_like

Detects whether T is a variant‐like type, i.e. exposes the std::variant‐style index()/`std::visit` interface.

join_view

A view over the iterator range [begin, end)] that formats its elements separated by sep, produced by fmt::join.

loc_value

A type‐erased formatting argument passed to a format_facet for locale‐aware formatting.

locale_ref

A type‐erased reference to std::locale to avoid the heavy <locale> include.

locking

Detects whether formatting an object of type T requires locking, e.g. because it accesses global state such as the current locale.

monostate

An empty placeholder type used where a value is required by the API but carries no information, e.g. as the mapped type for arguments that don't match any supported formatting type.

nested_formatter

Base class for formatters that nest another formatter and support applying a width and alignment to its overall output, such as formatter<std::pair<T, U>>.

nested_view

Pairs a value with the formatter that should be used to format it, so it can be formatted through a formatter<nested_view<T, Char>, Char> specialization by an enclosing formatter.

parse_context

Parsing context consisting of a format string range being parsed and an argument counter for automatic indexing.

path

A std::filesystem::path subclass whose string()‐like accessors return UTF‐8 encoded strings regardless of platform.

range_format_kind

Determines the range_format used to format T, e.g. map, set, string, or disabled if T is not a formattable range.

range_formatter

Formats a range as a bracketed, separator‐delimited sequence of its elements.

rgb

A color represented as separate red, green, and blue components.

runtime_format_string

A format string that skips compile‐time checks and is validated at runtime instead, as returned by runtime.

static_format_result

Holds a null‐terminated string of exactly N ‐ 1 characters, produced by formatting a compiled format string at compile time.

string_buffer

A std::string‐backed buffer that can be converted to a writer.

text_style

A text style consisting of foreground and background colors and emphasis.

tuple_join_view

A view over tuple that formats its elements separated by sep, produced by fmt::join.

vprintf_args

A helper that maps a character type to the type‐erased argument list used with basic_printf_context<Char>.

writer

A writer to a buffered stream. It doesn't own the underlying stream.

Type Aliases

Name

Description

appender

A basic_appender specialized for char.

basic_format_context

Format context type for a given output iterator and character type, resolving to context when OutputIt is appender and to generic_context<OutputIt, Char> otherwise.

basic_format_parse_context

Alias of parse_context<Char> kept for C++20 std::format compatibility.

basic_format_string

A format string for character type Char that is validated at compile time.

bool_constant

Alias for std::integral_constant<bool, B>, provided for compilers that predate C++17's std::bool_constant.

buffered_context

Format context type used by fmt::format overloads that write through a back_insert_iterator, resolving to context for char and to generic_context<basic_appender<Char>, Char> otherwise.

conditional_t

Alias for std::conditional<B, T, F>::type, provided for compilers that predate C++14's std::conditional_t.

cstring_view

A basic_cstring_view for char strings.

day

decay_t

Alias for std::decay<T>::type, provided for compilers that predate C++14's std::decay_t.

enable_if_t

Alias for std::enable_if<B, T>::type, provided for compilers that predate C++14's std::enable_if_t.

format_args

Alias of basic_format_args<context> used by the default format API.

format_context

Alias of context kept for C++20 std::format compatibility.

format_parse_context

Alias of parse_context<char> kept for C++20 std::format compatibility.

format_string

A format string that is validated at compile time.

is_formattable

A trait indicating whether T can be formatted with character type Char.

local_time

A time point on the local clock, with the given Duration resolution.

make_unsigned_t

Alias for std::make_unsigned<T>::type, provided for compilers that predate C++14's std::make_unsigned_t.

memory_buffer

A memory buffer for char with the default inline capacity.

month

named_arg

An argument bound to a name, as returned by fmt::arg, that lets a format string refer to it by name instead of by position.

nullptr_t

The type of the nullptr literal.

ostream_formatter

A basic_ostream_formatter for char strings.

printf_args

The type‐erased argument list used with printf_context.

printf_context

A basic_printf_context for char strings.

remove_const_t

Alias for std::remove_const<T>::type, provided for compilers that predate C++14's std::remove_const_t.

remove_cvref_t

Alias for std::remove_cv<std::remove_reference<T>::type>::type, provided for compilers that predate C++20's std::remove_cvref_t.

remove_reference_t

Alias for std::remove_reference<T>::type, provided for compilers that predate C++14's std::remove_reference_t.

string_view

A basic_string_view specialized for char.

sys_time

A time point on the system clock, with the given Duration resolution.

ullong

Alias for unsigned long long.

underlying_t

Alias for std::underlying_type<T>::type, provided for compilers that predate C++14's std::underlying_type_t.

utc_time

A time point on the UTC clock, with the given Duration resolution.

vargs

The type returned by make_format_args for the default context.

void_t

Alias that maps any set of types to void, used to detect the validity of an expression in SFINAE contexts.

wcstring_view

A basic_cstring_view for wchar_t strings.

weekday

wformat_args

A wchar_t counterpart of format_args.

wformat_context

A wchar_t counterpart of context.

wformat_parse_context

A wchar_t counterpart of format_parse_context.

wformat_string

A wchar_t counterpart of format_string.

wmemory_buffer

A wchar_t counterpart of memory_buffer.

wprintf_args

The type‐erased argument list used with wprintf_context.

wprintf_context

A basic_printf_context for wchar_t strings.

wstring_view

A wchar_t counterpart of string_view.

year

year_month_day

Enums

Name

Description

Unnamed enum

The number of characters to store in the basic_memory_buffer object itself to avoid dynamic memory allocation.

align

The alignment of a formatted value within its field width.

arg_id_kind

The kind of dynamic argument, if any, used to supply a field width or precision.

color

A named color from the extended CSS/X11 color set, encoded as a packed 0xRRGGBB value.

emphasis

A bitmask of text emphasis styles that can be combined with operator|.

presentation_type

The presentation type of a format specifier, encoding which of the mutually exclusive type letters (e.g. 'd', 'x', 'f', 's') was used. Enumerators for unrelated categories (integral/character, string/pointer, floating‐point) intentionally share numeric values because at most one category applies to a given argument type.

range_format

The style used to format a range or range‐like type.

sign

The sign specifier controlling how the sign of a numeric value is formatted.

terminal_color

Terminal colors that map to the standard ANSI SGR foreground color codes.

Functions

Name

Description

arg

arg overloads

assert_fail [noreturn]

Reports an assertion failure, used by the FMT_ASSERT macro when condition evaluates to false.

bg

Creates a text style from the background color.

fg

Creates a text style from the foreground (text) color.

format

format overloads

format_system_error

Formats an error message for an error returned by an operating system or a language runtime, for example a file opening error, and writes it to out. The format is the same as the one used by std::system_error(ec, message) where ec is std::error_code(error_code, std::generic_category()). It is implementation‐defined but normally looks like:

format_to

format_to overloads

format_to_n

format_to_n overloads

formatted_size

formatted_size overloads

fprintf

fprintf overloads

gmtime

gmtime overloads

group_digits

Returns a view that formats an integer value using ',' as a locale‐independent thousands separator.

join

join overloads

make_format_args

Constructs an object that stores references to arguments and can be implicitly converted to format_args. Context can be omitted in which case it defaults to context. See arg for lifetime considerations.

make_printf_args

Constructs an format_arg_store object that contains references to arguments and can be implicitly converted to printf_args.

make_wformat_args

A wchar_t counterpart of make_format_args.

max_of

Returns the larger of a and b.

min_of

Returns the smaller of a and b.

operator""_a

User‐defined literal equivalent of fmt::arg, but with compile‐time checks.

operator""_cf

Converts a string literal into a format string that will be parsed at compile time and converted into efficient formatting code. Requires support for class types in constant template parameters (a C++20 feature).

operator|

Bitwise disjunction operators

print

print overloads

printf

Formats args according to specifications in fmt and writes the output to stdout.

println

println overloads

ptr

ptr overloads

report_error [noreturn]

Reports a format error at compile time or, via a format_error exception, at runtime.

report_system_error

Reports a system error without throwing an exception. Can be used to report errors from destructors.

runtime

runtime overloads

sprintf

sprintf overloads

streamed

Returns a view that formats value via an ostream operator<<.

styled

Returns an argument that will be formatted using ANSI escape sequences, to be used in a formatting function.

system_category

Returns the system error category used to construct std::system_error objects on non‐Windows platforms.

system_error

Constructs std::system_error with a message formatted with fmt::format(fmt, args...). error_code is a system error code as given by errno.

to_string

to_string overloads

to_wstring

Converts value to std::wstring using the default format for type T.

underlying

Converts e to the underlying type.

vformat

vformat overloads

vformat_to

vformat_to overloads

vformat_to_n

vformat_to_n overloads

vfprintf

Formats args according to specifications in fmt and writes the output to the file f.

vprint

vprint overloads

vprint_buffered

Formats args according to specifications in fmt into a buffer and writes the buffer to the file f in a single write.

vprintln

vprintln overloads

vsprintf

Formats args according to specifications in fmt and returns the result as a string.

vsystem_error

Constructs std::system_error with a message formatted with fmt::vformat(fmt, args).

operator==

true if lhs and rhs are equal.

operator!=

true if lhs and rhs are not equal.

operator<

true if lhs is lexicographically less than rhs.

operator<=

true if lhs is lexicographically less than or equal to.

operator>

true if lhs is lexicographically greater than rhs.

operator>=

true if lhs is lexicographically greater than or equal to.

Concepts

Name

Description

formattable

A concept satisfied by types that can be formatted with character type Char.

fmt::enums namespace

Contains format_as overloads that make enum types formattable by converting them to their underlying type.

Functions

Name

Description

format_as

Converts e to its underlying type so that enum types are formattable by default via argument‐dependent lookup.

fmt::safe_duration_cast namespace

Helpers for converting between std::chrono::duration types without undefined behavior or erroneous results due to overflow.

Functions

Name

Description

lossless_integral_conversion

lossless_integral_conversion overloads

safe_duration_cast

Safe duration_cast between floating point durations

safe_float_conversion

safe_float_conversion overloads

Created with MrDocs