Created on 2024-04-30.00:00:00 last changed 2 weeks ago
Proposed resolution:
This wording is relative to N5008.
Modify [format.string.std] as indicated:
-17- When the `L` option is used, the form used for the conversion is called the locale-specific form. The `L` 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 with
numpunct<charT>::truename
ornumpunct<charT>::falsename
.
[ 2025-06-12; Jonathan provides wording ]
[ 2024-06-12; SG16 meeting ]
The three major implementations all use `numpunct` but not `num_put`, clarify that this is the intended behaviour.
[ 2024-05-08; Reflector poll ]
Set priority to 3 after reflector poll.
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 [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.
History | |||
---|---|---|---|
Date | User | Action | Args |
2025-06-12 10:39:03 | admin | set | messages: + msg14789 |
2025-06-12 10:39:03 | admin | set | messages: + msg14788 |
2025-06-12 10:39:03 | admin | set | messages: + msg14787 |
2024-05-08 10:05:54 | admin | set | messages: + msg14116 |
2024-05-08 10:05:54 | admin | set | status: new -> open |
2024-04-30 00:00:00 | admin | create |