|
| 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>§[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<class InputIterator, class OutputIterator1, class OutputIterator2, class Predicate> |
| 31 | + constexpr pair<OutputIterator1, OutputIterator2> |
| 32 | + partition_copy(InputIterator first, InputIterator last, |
| 33 | + OutputIterator1 out_true, OutputIterator2 out_false, Predicate pred); |
| 34 | +[…] |
| 35 | +template<<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<projected<iterator_t<R>, Proj>> Pred> |
| 39 | + requires indirectly_copyable<iterator_t<R>, iterator_t<OutR1>> && |
| 40 | + indirectly_copyable<iterator_t<R>, iterator_t<OutR2>> |
| 41 | + ranges::partition_copy_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR1>, |
| 42 | + borrowed_iterator_t<OutR2>> |
| 43 | + ranges::partition_copy(Ep&& exec, R&& r, OutR1&& out_true_r, OutR2&& 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 | +[…] |
| 52 | +<p/> |
| 53 | +-19- <i>Preconditions</i>: The input range and output ranges do not overlap. […] |
| 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) — <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) — <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 | +</ul> |
| 73 | +<p> |
| 74 | +-22- <i>Complexity</i>: At `most last - first` applications of `pred` and `proj`. |
| 75 | +</p> |
| 76 | +</blockquote> |
| 77 | +</blockquote> |
| 78 | +</li> |
| 79 | +</ol> |
| 80 | + |
| 81 | +</resolution> |
| 82 | + |
| 83 | +</issue> |
0 commit comments