Skip to content

Commit 010dac6

Browse files
timsong-cppjwakely
authored andcommitted
New issue: Fix default template arguments for ranges::replace and ranges::replace_if
1 parent 2ece056 commit 010dac6

File tree

1 file changed

+160
-0
lines changed

1 file changed

+160
-0
lines changed

xml/issue4444.xml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4444" status="New">
5+
<title>Fix default template arguments for `ranges::replace` and `ranges::replace_if`</title>
6+
<section>
7+
<sref ref="[alg.replace]"/><sref ref="[algorithm.syn]"/>
8+
</section>
9+
<submitter>Tim Song</submitter>
10+
<date>04 Nov 2025</date>
11+
<priority>99</priority>
12+
13+
<discussion>
14+
<b>Addresses <a href="https://github.com/cplusplus/nbballot/issues/834">US 159-259</a></b>
15+
<p>The default template argument for the type of the new value in
16+
`ranges::replace` and `ranges::replace_if` should not have projections applied.</p>
17+
</discussion>
18+
19+
<resolution>
20+
<p>
21+
This wording is relative to <paper num="N5014"/>.
22+
</p>
23+
24+
<ol>
25+
26+
<li><p>Modify <sref ref="[algorithm.syn]"/>, header <tt>&lt;algorithm&gt;</tt> synopsis, as indicated:</p>
27+
28+
<blockquote>
29+
<pre>
30+
[&hellip;]
31+
namespace ranges {
32+
template&lt;input_iterator I, sentinel_for&lt;I&gt; S, class Proj = identity,
33+
class T1 = projected_value_t&lt;I, Proj&gt;, class T2 = <del>T1</del><ins>iter_value_t&lt;I&gt;</ins>&gt;
34+
requires indirectly_writable&lt;I, const T2&amp;&gt; &amp;&amp;
35+
indirect_binary_predicate&lt;ranges::equal_to, projected&lt;I, Proj&gt;, const T1*&gt;
36+
constexpr I
37+
replace(I first, S last, const T1&amp; old_value, const T2&amp; new_value, Proj proj = {});
38+
template&lt;input_range R, class Proj = identity,
39+
class T1 = projected_value_t&lt;iterator_t&lt;R&gt;, Proj&gt;, class T2 = <del>T1</del><ins>range_value_t&lt;R&gt;</ins>&gt;
40+
requires indirectly_writable&lt;iterator_t&lt;R&gt;, const T2&amp;&gt; &amp;&amp;
41+
indirect_binary_predicate&lt;ranges::equal_to,
42+
projected&lt;iterator_t&lt;R&gt;, Proj&gt;, const T1*&gt;
43+
constexpr borrowed_iterator_t&lt;R&gt;
44+
replace(R&amp;&amp; r, const T1&amp; old_value, const T2&amp; new_value, Proj proj = {});
45+
46+
template&lt;<i>execution-policy</i> Ep, random_access_iterator I, sized_sentinel_for&lt;I&gt; S,
47+
class Proj = identity, class T1 = projected_value_t&lt;I, Proj&gt;, class T2 = <del>T1</del><ins>iter_value_t&lt;I&gt;</ins>&gt;
48+
requires indirectly_writable&lt;I, const T2&amp;&gt; &amp;&amp;
49+
indirect_binary_predicate&lt;ranges::equal_to, projected&lt;I, Proj&gt;, const T1*&gt;
50+
I replace(Ep&amp;&amp; exec, I first, S last,
51+
const T1&amp; old_value, const T2&amp; new_value, Proj proj = {}); // <i>freestanding-deleted</i>
52+
template&lt;<i>execution-policy</i> Ep, <i>sized-random-access-range</i> R, class Proj = identity,
53+
class T1 = projected_value_t&lt;iterator_t&lt;R&gt;, Proj&gt;, class T2 = <del>T1</del><ins>range_value_t&lt;R&gt;</ins>&gt;
54+
requires indirectly_writable&lt;iterator_t&lt;R&gt;, const T2&amp;&gt; &amp;&amp;
55+
indirect_binary_predicate&lt;ranges::equal_to,
56+
projected&lt;iterator_t&lt;R&gt;, Proj&gt;, const T1*&gt;
57+
borrowed_iterator_t&lt;R&gt;
58+
replace(Ep&amp;&amp; exec, R&amp;&amp; r, const T1&amp; old_value, const T2&amp; new_value,
59+
Proj proj = {}); // <i>freestanding-deleted</i>
60+
61+
template&lt;input_iterator I, sentinel_for&lt;I&gt; S, class Proj = identity,
62+
class T = <del>projected_</del><ins>iter_</ins>value_t&lt;I, Proj&gt;,
63+
indirect_unary_predicate&lt;projected&lt;I, Proj&gt;&gt; Pred&gt;
64+
requires indirectly_writable&lt;I, const T&amp;&gt;
65+
constexpr I replace_if(I first, S last, Pred pred, const T&amp; new_value, Proj proj = {});
66+
template&lt;input_range R, class Proj = identity, class T = <del>projected_value_t&lt;I</del><ins>range_value_t&lt;R</ins>, Proj&gt;,
67+
indirect_unary_predicate&lt;projected&lt;iterator_t&lt;R&gt;, Proj&gt;&gt; Pred&gt;
68+
requires indirectly_writable&lt;iterator_t&lt;R&gt;, const T&amp;&gt;
69+
constexpr borrowed_iterator_t&lt;R&gt;
70+
replace_if(R&amp;&amp; r, Pred pred, const T&amp; new_value, Proj proj = {});
71+
72+
template&lt;<i>execution-policy</i> Ep, random_access_iterator I, sized_sentinel_for&lt;I&gt; S,
73+
class Proj = identity, class T = <del>projected</del><ins>iter</ins>_value_t&lt;I, Proj&gt;,
74+
indirect_unary_predicate&lt;projected&lt;I, Proj&gt;&gt; Pred&gt;
75+
requires indirectly_writable&lt;I, const T&amp;&gt;
76+
I replace_if(Ep&amp;&amp; exec, I first, S last, Pred pred,
77+
const T&amp; new_value, Proj proj = {}); // <i>freestanding-deleted</i>
78+
template&lt;<i>execution-policy</i> Ep, <i>sized-random-access-range</i> R, class Proj = identity,
79+
class T = <del>projected_value_t&lt;iterator_t&lt;R&gt;</del><ins>range_value_t&lt;R</ins>, Proj&gt;,
80+
indirect_unary_predicate&lt;projected&lt;iterator_t&lt;R&gt;, Proj&gt;&gt; Pred&gt;
81+
requires indirectly_writable&lt;iterator_t&lt;R&gt;, const T&amp;&gt;
82+
borrowed_iterator_t&lt;R&gt;
83+
replace_if(Ep&amp;&amp; exec, R&amp;&amp; r, Pred pred, const T&amp; new_value,
84+
Proj proj = {}); // <i>freestanding-deleted</i>
85+
}
86+
[&hellip;]
87+
</pre>
88+
</blockquote>
89+
</li>
90+
<li><p>Modify <sref ref="[alg.replace]"/> as indicated:</p>
91+
92+
<blockquote>
93+
<pre>
94+
[&hellip;]
95+
template&lt;input_iterator I, sentinel_for&lt;I&gt; S, class Proj = identity,
96+
class T1 = projected_value_t&lt;I, Proj&gt;, class T2 = <del>T1</del><ins>iter_value_t&lt;I&gt;</ins>&gt;
97+
requires indirectly_writable&lt;I, const T2&amp;&gt; &amp;&amp;
98+
indirect_binary_predicate&lt;ranges::equal_to, projected&lt;I, Proj&gt;, const T1*&gt;
99+
constexpr I
100+
ranges::replace(I first, S last, const T1&amp; old_value, const T2&amp; new_value, Proj proj = {});
101+
template&lt;input_range R, class Proj = identity,
102+
class T1 = projected_value_t&lt;iterator_t&lt;R&gt;, Proj&gt;, class T2 = <del>T1</del><ins>range_value_t&lt;R&gt;</ins>&gt;
103+
requires indirectly_writable&lt;iterator_t&lt;R&gt;, const T2&amp;&gt; &amp;&amp;
104+
indirect_binary_predicate&lt;ranges::equal_to,
105+
projected&lt;iterator_t&lt;R&gt;, Proj&gt;, const T1*&gt;
106+
constexpr borrowed_iterator_t&lt;R&gt;
107+
ranges::replace(R&amp;&amp; r, const T1&amp; old_value, const T2&amp; new_value, Proj proj = {});
108+
109+
template&lt;<i>execution-policy</i> Ep, random_access_iterator I, sized_sentinel_for&lt;I&gt; S,
110+
class Proj = identity, class T1 = projected_value_t&lt;I, Proj&gt;, class T2 = <del>T1</del><ins>iter_value_t&lt;I&gt;</ins>&gt;
111+
requires indirectly_writable&lt;I, const T2&amp;&gt; &amp;&amp;
112+
indirect_binary_predicate&lt;ranges::equal_to, projected&lt;I, Proj&gt;, const T1*&gt;
113+
I ranges::replace(Ep&amp;&amp; exec, I first, S last,
114+
const T1&amp; old_value, const T2&amp; new_value, Proj proj = {});
115+
template&lt;<i>execution-policy</i> Ep, <i>sized-random-access-range</i> R, class Proj = identity,
116+
class T1 = projected_value_t&lt;iterator_t&lt;R&gt;, Proj&gt;, class T2 = <del>T1</del><ins>range_value_t&lt;R&gt;</ins>&gt;
117+
requires indirectly_writable&lt;iterator_t&lt;R&gt;, const T2&amp;&gt; &amp;&amp;
118+
indirect_binary_predicate&lt;ranges::equal_to,
119+
projected&lt;iterator_t&lt;R&gt;, Proj&gt;, const T1*&gt;
120+
borrowed_iterator_t&lt;R&gt;
121+
ranges::replace(Ep&amp;&amp; exec, R&amp;&amp; r, const T1&amp; old_value, const T2&amp; new_value,
122+
Proj proj = {});
123+
124+
template&lt;input_iterator I, sentinel_for&lt;I&gt; S, class Proj = identity,
125+
class T = <del>projected_</del><ins>iter_</ins>value_t&lt;I, Proj&gt;,
126+
indirect_unary_predicate&lt;projected&lt;I, Proj&gt;&gt; Pred&gt;
127+
requires indirectly_writable&lt;I, const T&amp;&gt;
128+
constexpr I ranges::replace_if(I first, S last, Pred pred, const T&amp; new_value, Proj proj = {});
129+
template&lt;input_range R, class Proj = identity, class T = <del>projected_value_t&lt;I</del><ins>range_value_t&lt;R</ins>, Proj&gt;,
130+
indirect_unary_predicate&lt;projected&lt;iterator_t&lt;R&gt;, Proj&gt;&gt; Pred&gt;
131+
requires indirectly_writable&lt;iterator_t&lt;R&gt;, const T&amp;&gt;
132+
constexpr borrowed_iterator_t&lt;R&gt;
133+
ranges::replace_if(R&amp;&amp; r, Pred pred, const T&amp; new_value, Proj proj = {});
134+
135+
template&lt;<i>execution-policy</i> Ep, random_access_iterator I, sized_sentinel_for&lt;I&gt; S,
136+
class Proj = identity, class T = <del>projected</del><ins>iter</ins>_value_t&lt;I, Proj&gt;,
137+
indirect_unary_predicate&lt;projected&lt;I, Proj&gt;&gt; Pred&gt;
138+
requires indirectly_writable&lt;I, const T&amp;&gt;
139+
I ranges::replace_if(Ep&amp;&amp; exec, I first, S last, Pred pred,
140+
const T&amp; new_value, Proj proj = {});
141+
template&lt;<i>execution-policy</i> Ep, <i>sized-random-access-range</i> R, class Proj = identity,
142+
class T = <del>projected_value_t&lt;iterator_t&lt;R&gt;</del><ins>range_value_t&lt;R</ins>, Proj&gt;,
143+
indirect_unary_predicate&lt;projected&lt;iterator_t&lt;R&gt;, Proj&gt;&gt; Pred&gt;
144+
requires indirectly_writable&lt;iterator_t&lt;R&gt;, const T&amp;&gt;
145+
borrowed_iterator_t&lt;R&gt;
146+
ranges::replace_if(Ep&amp;&amp; exec, R&amp;&amp; r, Pred pred, const T&amp; new_value,
147+
Proj proj = {});
148+
</pre>
149+
<blockquote>
150+
<p>
151+
-1- [&hellip;]
152+
</p>
153+
</blockquote>
154+
</blockquote>
155+
</li>
156+
</ol>
157+
158+
</resolution>
159+
160+
</issue>

0 commit comments

Comments
 (0)