HomeManualTopicsTypesSymbols

std::format

formats its arguments using the specified template string

Parameters

template
the template string
arguments*
the embedded arguments

Results

None

Description

The template contains a format specifier for each argument.

Each format specifier start with a '%'-character and is folled by a length and (optionally) by a '.'-character and a second length specifying the number of decimal places.

E.g. "%3.1" is a format specifier to print a real number with 3 digits, followed by a decimal point and 1 decimal place.

If the size of the number exceeds the specified number of digits then the number is displayed anyways (ignoring the format specification).

If the '%'-character is immediately followed by an 'l' or an 'r' it ist left- respectively righ-justified. The default is right justification.

To print a character that might me misinterpreted as a part of a format specifier ('%', '.' or a digit) precede it with a backslash character ('\'). This is also the way to print a backslash itself.

The function returns the constructed string or std::undefined if the template string contains invalid format specifiers.

Topic

Strings