Skip to content

Commit bb2370d

Browse files
committed
New issue from Hewill: "Redundant constraint in range_formatter::format"
1 parent 5dcea8b commit bb2370d

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

xml/issue4246.xml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4246" status="New">
5+
<title>Redundant constraint in `range_formatter::format`</title>
6+
<section>
7+
<sref ref="[format.range.formatter]"/>
8+
</section>
9+
<submitter>Hewill Kang</submitter>
10+
<date>18 Apr 2025</date>
11+
<priority>99</priority>
12+
13+
<discussion>
14+
<p>
15+
Currently, the signature of `range_formatter::format` is as follows:
16+
</p>
17+
<blockquote><pre>
18+
template&lt;ranges::input_range R, class FormatContext&gt;
19+
requires formattable&lt;ranges::range_reference_t&lt;R&gt;, charT&gt; &amp;&amp;
20+
same_as&lt;remove_cvref_t&lt;ranges::range_reference_t&lt;R&gt;&gt;, T&gt;
21+
typename FormatContext::iterator
22+
format(R&amp;&amp; r, FormatContext&amp; ctx) const;
23+
</pre></blockquote>
24+
<p>
25+
which requires that the reference type of the range parameter must be `formattable`,
26+
and such type must be exactly `T` after removing the <i>cvref</i>-qualifiers.
27+
</p>
28+
<p>
29+
However, satisfying the latter always implies satisfying the former, as the `range_formatter` class
30+
already requires that `T` must be `formattable`.
31+
</p>
32+
<p>
33+
There is no need to perform a redundant check here.
34+
</p>
35+
</discussion>
36+
37+
<resolution>
38+
<p>
39+
This wording is relative to <paper num="N5008"/>.
40+
</p>
41+
42+
<ol>
43+
44+
<li><p>Modify <sref ref="[format.range.formatter]"/> as indicated:</p>
45+
46+
<blockquote>
47+
<blockquote>
48+
<pre>
49+
namespace std {
50+
template&lt;class T, class charT = char&gt;
51+
requires same_as&lt;remove_cvref_t&lt;T>, T> &amp;&amp; formattable&lt;T, charT&gt;
52+
class range_formatter {
53+
[&hellip;]
54+
template&lt;ranges::input_range R, class FormatContext&gt;
55+
requires <del>formattable&lt;ranges::range_reference_t&lt;R&gt;, charT&gt; &amp;&amp;</del>
56+
same_as&lt;remove_cvref_t&lt;ranges::range_reference_t&lt;R&gt;&gt;, T&gt;
57+
typename FormatContext::iterator
58+
format(R&amp;&amp; r, FormatContext&amp; ctx) const;
59+
};
60+
}
61+
</pre>
62+
</blockquote>
63+
[&hellip;]
64+
<pre>
65+
template&lt;ranges::input_range R, class FormatContext&gt;
66+
requires <del>formattable&lt;ranges::range_reference_t&lt;R&gt;, charT&gt; &amp;&amp;</del>
67+
same_as&lt;remove_cvref_t&lt;ranges::range_reference_t&lt;R&gt;&gt;, T&gt;
68+
typename FormatContext::iterator
69+
format(R&amp;&amp; r, FormatContext&amp; ctx) const;
70+
</pre>
71+
<blockquote>
72+
<p>
73+
-11- <i>Effects</i>: Writes the following into <code>ctx.out()</code>, adjusted according to the
74+
<i>range-format-spec</i>:
75+
</p>
76+
</blockquote>
77+
</blockquote>
78+
79+
</li>
80+
81+
</ol>
82+
</resolution>
83+
84+
</issue>

0 commit comments

Comments
 (0)