This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of SG16 status.
std::format
Section: 28.5.2.2 [format.string.std] Status: SG16 Submitter: Jens Maurer Opened: 2024-04-30 Last modified: 2025-06-12
Priority: 3
View other active issues in [format.string.std].
View all other issues in [format.string.std].
View all issues with SG16 status.
Discussion:
There are std::format
variants that take an explicit std::locale
parameter.
There is the "L"
format specifier that uses that locale (or some environment
locale) for formatting, according to 28.5.2.2 [format.string.std] p17:
"For integral types, the locale-specific form causes the context's locale to be used to insert the appropriate digit group separator characters."
It is unclear which specific facets are used to make this happen. This is important, because users can install their own facets into a given locale. Specific questions include:
Is num_put<>
being used? Or just numpunct<>
?
Are any of the _byname
facets being used?
Assuming the encoding for char
is UTF-8, the use of a user-provided
num_put<>
facet (as opposed to std::format
creating the output based on
numpunct<>
) would allow digit separators that are not expressibly as a
single UTF-8 code unit.
[2024-05-08; Reflector poll]
Set priority to 3 after reflector poll.
[2024-06-12; SG16 meeting]
The three major implementations all use numpunct
but not num_put
,
clarify that this is the intended behaviour.
[2025-06-12; Jonathan provides wording]
Proposed resolution:
This wording is relative to N5008.
Modify 28.5.2.2 [format.string.std] as indicated:
-17- When theL
option is used, the form used for the conversion is called the locale-specific form. TheL
option is only valid for arithmetic types, and its effect depends upon the type.
- (17.1) — For integral types, the locale-specific form causes the context’s locale to be used to insert the appropriate digit group separator characters as if obtained with
numpunct<charT>::grouping
andnumpunct<charT>::thousands_sep
.- (17.2) — For floating-point types, the locale-specific form causes the context’s locale to be used to insert the appropriate digit group and radix separator characters as if obtained with
numpunct<charT>::grouping
,numpunct<charT>::thousands_sep
, andnumpunct<charT>::decimal_point
.- (17.3) — For the textual representation of
bool
, the locale-specific form causes the context’s locale to be used to insert the appropriate string as if obtained withnumpunct<charT>::truename
ornumpunct<charT>::falsename
.