Skip to content

Commit 3edd0c6

Browse files
committed
New issue from Jiang An: "Integer-class types should be formattable"
1 parent 6252da2 commit 3edd0c6

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

xml/issue4284.xml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4284" status="New">
5+
<title>Integer-class types should be formattable</title>
6+
<section>
7+
<sref ref="[format.formatter.spec]"/>
8+
</section>
9+
<submitter>Jiang An</submitter>
10+
<date>27 Jun 2025</date>
11+
<priority>99</priority>
12+
13+
<discussion>
14+
<p>
15+
The following program doesn't compile with MSVC STL (<a href="https://godbolt.org/z/aazK6bhqM">Godbolt link</a>).
16+
</p>
17+
<blockquote><pre>
18+
#include &lt;format&gt;
19+
#include &lt;ranges&gt;
20+
21+
int main() {
22+
auto iv1 = std::views::iota(42ull, 1729ull);
23+
auto iv2 = std::views::iota(iv1.begin(), iv1.end());
24+
std::format("{}", iv2.size()); // <span style="color:red;font-weight:bolder">Error</span>
25+
}
26+
</pre></blockquote>
27+
<p>
28+
In MSVC STL, the type of `iv2.size()` is an integer-class type, and the standard hasn't guaranteed there're
29+
enabled formatter specializations for integer-class types. As a result, this program is not guaranteed to
30+
be well-formed.
31+
<p/>
32+
Perhaps we should require enabled `std::formatter` specializations for integer-class types to get rid of
33+
such uncertainty and inconsistency.
34+
</p>
35+
</discussion>
36+
37+
<resolution>
38+
<p>
39+
This wording is relative to <paper num="N5008"/>.
40+
</p>
41+
42+
<ol>
43+
<li><p>Modify <sref ref="[format.formatter.spec]"/> as indicated:</p>
44+
45+
<blockquote>
46+
<p>
47+
-2- [&hellip;] Each header that declares the template
48+
`formatter` provides the following enabled specializations:
49+
</p>
50+
<ol style="list-style-type: none">
51+
<li><p>(2.1) &mdash; [&hellip;]</p></li>
52+
<li><p>(2.2) &mdash; [&hellip;]</p></li>
53+
<li><p>(2.3) &mdash; [&hellip;]</p></li>
54+
<li><p><ins>(2.?) &mdash; For each `charT`, for each cv-unqualified integer-class type
55+
(<sref ref="[iterator.concept.winc]"/>) `IntegerClass`, a specialization</ins>
56+
</p>
57+
<blockquote><pre>
58+
<ins>template&lt;&gt; struct formatter&lt;IntegerClass, charT&gt;;</ins>
59+
</pre></blockquote>
60+
</li>
61+
<li><p>(2.4) &mdash; [&hellip;]</p></li>
62+
</ol>
63+
</blockquote>
64+
</li>
65+
66+
</ol>
67+
</resolution>
68+
69+
</issue>

0 commit comments

Comments
 (0)