This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.
Section: 22.14.2 [format.string] Status: C++20 Submitter: Richard Smith Opened: 2019-08-02 Last modified: 2021-02-25
Priority: 2
View all other issues in [format.string].
View all issues with C++20 status.
Discussion:
We are told:
Formatting of objects of arithmetic types and const void* is done as if by calling to_chars (unless otherwise specified) and copying the output through the output iterator of the format context with additional padding and adjustments as specified by the format specifiers.
… but there is no corresponding rule for strings. Is an alignment specifier intended to be applied to strings or not? The wording as-is is ambiguous.
(The above also doesn't cover formatting void* or std::nullptr_t. Presumably at least those two should have the relevant adjustments applied to them!) The wording never actually anywhere says that the basic_format_args are in any way involved in the formatting process, or how formatting actually happens. (The wording doesn't say that basic_format_arg::handle::format is ever called, for example.) Victor Zverovich: An alignment specifier is intended to be applied to strings as well, void* and std::nullptr_t are converted into const void* when constructing basic_format_arg. The wording for vformat and similar functions says that basic_format_args is involved:Returns: A string object holding the character representation of formatting arguments provided by args formatted according to specifications given in fmt.
but I admit that it is hand-wavy. Perhaps we could add something along the lines of
For each replacement field referring to the argument with index (arg-id) i, the basic_format_arg object referring to the argument is obtained via args.get(i) and the parse and format functions of the formatter specialization for the underlying argument type are called to parse the format specification and format the value.
to clarify how we format args (basic_format_args).
[2019-08-21 Priority set to 2 based on reflector discussion]
[2019-08-21; Victor Zverovich suggests wording]
[2020-02 Status to Immediate on Thursday night in Prague.]
Proposed resolution:
This wording is relative to N4830.
Modify 22.14.2.2 [format.string.std] as indicated:
-3- The align specifier applies to all argument types. The meaning of the various alignment options is as specified in Table [tab:format.align]. [Example: […