Title
std::formatter specializations should be consistently restricted to supported character types
Status
new
Section
[format.syn][time.syn][thread.thread.id]
Submitter
Jiang An

Created on 2023-10-15.00:00:00 last changed 8 months ago

Messages

Date: 2023-11-15.00:00:00

[ 2023-11-03; Reflector poll ]

Set priority to 4 after reflector poll. "Problem looks theoretical, all entry points to formatters are constrained."

Date: 2023-10-15.00:00:00

[format.formatter.spec]/2 requires some std::formatter specializations are only enabled for character types char and wchar_t. But for specializations that are explicitly shown in the synopses ([format.syn], [time.syn], and [thread.thread.id]), there is no such restrictions for charT. The difference may be observable via the std::formattable concept, e.g. std::formattable<std::chrono::second, char8_t> is currently satisfied, even though there would be a hard error during formatting due to STATICALLY-WIDEN.

Perhaps we should introduce an exposition-only concept that is only satisfied (and modeled) by char and wchar_t for now, and constrain the charT template parameter of all std::formatter specializations that are explicitly mentioned in synopses with that concept. This is what libc++ currently implements (e.g. the __fmt_char_type concept and its usage in <chrono>).

History
Date User Action Args
2023-11-03 18:08:28adminsetmessages: + msg13810
2023-10-15 00:00:00admincreate