Skip to content

Commit b50162d

Browse files
committed
New issue from Ruslan Arutyunyan: "§[alg.partitions] Clarify Returns: element"
1 parent dc3fb7d commit b50162d

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

xml/issue4465.xml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4465" status="New">
5+
<title>&sect;[alg.partitions] Clarify <i>Returns:</i> element</title>
6+
<section><sref ref="[alg.partitions]"/></section>
7+
<submitter>Ruslan Arutyunyan</submitter>
8+
<date>07 Nov 2025</date>
9+
<priority>99</priority>
10+
11+
<discussion>
12+
<b>Addresses <a href="https://github.com/cplusplus/nbballot/issues/836">US 162-261</a></b>
13+
<p>
14+
In <sref ref="[alg.partitions]"/> p21 the wording is unclear what happens if there is not such element.
15+
The proposed resolution tries to clarify that without complicating the wording. If the proposed resolution
16+
(or something along those lines) fails, the recommendation is to reject US 162-261.
17+
</p>
18+
</discussion>
19+
20+
<resolution>
21+
<p>
22+
This wording is relative to <paper num="N5014"/>.
23+
</p>
24+
25+
<ol>
26+
<li><p>Modify <sref ref="[alg.partitions]"/>, as indicated:</p>
27+
28+
<blockquote>
29+
<pre>
30+
template&lt;class InputIterator, class OutputIterator1, class OutputIterator2, class Predicate&gt;
31+
constexpr pair&lt;OutputIterator1, OutputIterator2&gt;
32+
partition_copy(InputIterator first, InputIterator last,
33+
OutputIterator1 out_true, OutputIterator2 out_false, Predicate pred);
34+
[&hellip;]
35+
template&lt;<i>execution-policy</i> Ep, <i>sized-random-access-range</i> R,
36+
<i>sized-random-access-range</i> OutR1, <i>sized-random-access-range</i> OutR2,
37+
class Proj = identity,
38+
indirect_unary_predicate&lt;projected&lt;iterator_t&lt;R&gt;, Proj&gt;&gt; Pred&gt;
39+
requires indirectly_copyable&lt;iterator_t&lt;R&gt;, iterator_t&lt;OutR1&gt;&gt; &amp;&amp;
40+
indirectly_copyable&lt;iterator_t&lt;R&gt;, iterator_t&lt;OutR2&gt;&gt;
41+
ranges::partition_copy_result&lt;borrowed_iterator_t&lt;R&gt;, borrowed_iterator_t&lt;OutR1&gt;,
42+
borrowed_iterator_t&lt;OutR2&gt;&gt;
43+
ranges::partition_copy(Ep&amp;&amp; exec, R&amp;&amp; r, OutR1&amp;&amp; out_true_r, OutR2&amp;&amp; out_false_r,
44+
Pred pred, Proj proj = {});
45+
</pre>
46+
<blockquote>
47+
<p>
48+
-14- Let `proj` be `identity{}` for the overloads with no parameter named `proj` and let
49+
<tt><i>E</i>(x)</tt> be <tt>bool(invoke(pred, invoke(proj, x)))</tt>.
50+
<p/>
51+
[&hellip;]
52+
<p/>
53+
-19- <i>Preconditions</i>: The input range and output ranges do not overlap. [&hellip;]
54+
<p/>
55+
-20- <i>Effects</i>: For each iterator `i` in <tt>[first, first + <i>N</i>)</tt>, copies `*i`
56+
to the output range `[out_true, last_true)` if <tt><i>E</i>(*i)</tt> is `true`, or to the
57+
output range `[out_false, last_false)` otherwise.
58+
<p/>
59+
-21- <i>Returns</i>: Let <del>`o1`</del><ins><tt><i>Q</i></tt></ins> be the <del>iterator past the
60+
last</del><ins>number of</ins> copied element<ins>s</ins> in<ins>to</ins> the output range
61+
`[out_true, last_true)`, and <del>`o2`</del><ins><tt><i>V</i></tt></ins> be the <del>iterator past the
62+
last</del><ins> number of</ins> copied element<ins>s</ins> in<ins>to</ins> the output range
63+
`[out_false, last_false)`. Returns:
64+
</p>
65+
<ul style="list-style-type: none">
66+
<li>(21.1) &mdash; <tt>{<del>o1</del><ins>out_true + <i>Q</i></ins>, <del>o2</del><ins>out_false + <i>V</i></ins>}</tt>
67+
for the overloads in namespace `std`.
68+
</li>
69+
<li>(21.2) &mdash; <tt>{first + <i>N</i>, <del>o1</del><ins>out_true + <i>Q</i></ins>,
70+
<del>o2</del><ins>out_false + <i>V</i></ins>}</tt> for the overloads in namespace `ranges`.
71+
</li>
72+
<p>
73+
-22- <i>Complexity</i>: At `most last - first` applications of `pred` and `proj`.
74+
</p>
75+
</ul>
76+
</blockquote>
77+
</blockquote>
78+
</li>
79+
</ol>
80+
81+
</resolution>
82+
83+
</issue>

0 commit comments

Comments
 (0)