forked from lwg/issues
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New issue from Jiang An: "std::formatter specializations should be co…
…nsistently restricted to supported character types"
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version='1.0' encoding='utf-8' standalone='no'?> | ||
<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> | ||
|
||
<issue num="3997" status="New"> | ||
<title><tt>std::formatter</tt> specializations should be consistently restricted to supported character types</title> | ||
<section><sref ref="[format.syn]"/><sref ref="[time.syn]"/><sref ref="[thread.thread.id]"/></section> | ||
<submitter>Jiang An</submitter> | ||
<date>15 Oct 2023</date> | ||
<priority>99</priority> | ||
|
||
<discussion> | ||
<p> | ||
<sref ref="[format.formatter.spec]"/>/2 requires some <tt>std::formatter</tt> specializations are only enabled | ||
for character types <tt>char</tt> and <tt>wchar_t</tt>. But for specializations that are explicitly shown in | ||
the synopses (<sref ref="[format.syn]"/>, <sref ref="[time.syn]"/>, and <sref ref="[thread.thread.id]"/>), | ||
there is no such restrictions for <tt>charT</tt>. The difference may be observable via the <tt>std::formattable</tt> | ||
concept, e.g. <tt>std::formattable<std::chrono::second, char8_t></tt> is currently satisfied, even though | ||
there would be a hard error during formatting due to <tt><i>STATICALLY-WIDEN</i></tt>. | ||
<p/> | ||
Perhaps we should introduce an exposition-only concept that is only satisfied (and modeled) by <tt>char</tt> and | ||
<tt>wchar_t</tt> for now, and constrain the <tt>charT</tt> template parameter of all <tt>std::formatter</tt> | ||
specializations that are explicitly mentioned in synopses with that concept. This is what libc++ currently | ||
implements (e.g. the | ||
<a href="https://github.com/llvm/llvm-project/blob/6dfea561ba96974b205c31546c5e2069429c75b1/libcxx/include/__format/concepts.h#L32-L38"><tt>__fmt_char_type</tt></a> | ||
concept and <a href="https://github.com/llvm/llvm-project/blob/main/libcxx/include/__chrono/formatter.h#L580-L825">its | ||
usage in <tt><chrono></tt></a>). | ||
</p> | ||
</discussion> | ||
|
||
<resolution> | ||
</resolution> | ||
|
||
</issue> |