This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
Section: 28.5.2.2 [format.string.std] Status: New Submitter: Mark de Wever Opened: 2021-09-05 Last modified: 2021-12-04
Priority: 2
View other active issues in [format.string.std].
View all other issues in [format.string.std].
View all issues with New status.
Discussion:
The alignment options specified in 28.5.2.2 [format.string.std], Table [tab:format.align] causes an inconsistency when formatting characters. The output differs depending on whether an integer is formatted using a character presentation type or when using a character directly:
format("{:3}", '*'); -> "* " // aligned at the start of the available space format("{:3c}", 42); -> " *" // aligned at the end of the available space
I expect both calls to return the same value: "* "
. The current wording
mixes the type and the presentation type. To me, it seems clearer to adjust to wording
to only use the presentation type. Another approach would be adjusting the wording to
add an exception when an integer type uses the character presentation.
[2021-09-20; Reflector poll]
Set priority to 2 after reflector poll.
Victor said "It mostly looks correct but I think the wording needs a bit more work because we don't mention arithmetic presentation types anywhere."
[2021-11-29; Daniel comments]
This issue touches the same wording area as LWG 3644(i) does.
Proposed resolution:
This wording is relative to N4892.
Modify 28.5.2.2 [format.string.std], Table [tab:format.align], as indicated:
Table 59 — Meaning of align options [tab:format.align] Option Meaning <
Forces the field to be aligned to the start of the available space. This is the default when the presentation type is a non-arithmetic type for non-arithmetic types,.charT
, andbool
, unless an integer presentation type is specified>
Forces the field to be aligned to the end of the available space. This is the default when the presentation type is an arithmetic type for arithmetic types other than.charT
andbool
or when an integer presentation type is specified[…]