|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4464" status="New"> |
| 5 | +<title>§[alg.merge] Wording tweaks</title> |
| 6 | +<section><sref ref="[alg.merge]"/></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/837">US 163-262</a></b> |
| 13 | +<p> |
| 14 | +The original text of the “US 163-262” issue says: “Bullets 1.3 and 1.4 and paragraph 3 should say <tt><i>E</i>(e1, e2)</tt> |
| 15 | +instead of <tt><i>E</i>(e1, e1)</tt>” in [alg.merge]. The problem, though, was introduced when merging |
| 16 | +<paper num="P3179R9"/> “Parallel Range Algorithms” proposal. The original wording of P3179 does not |
| 17 | +have parentheses after <tt><i>E</i></tt>. Those extra parameters in <tt><i>E</i></tt> do not bring clarity |
| 18 | +to `merge` algorithm. The proposed resolution is to strike them through. |
| 19 | +</p> |
| 20 | +</discussion> |
| 21 | + |
| 22 | +<resolution> |
| 23 | +<p> |
| 24 | +This wording is relative to <paper num="N5014"/>. |
| 25 | +</p> |
| 26 | + |
| 27 | +<ol> |
| 28 | +<li><p>Modify <sref ref="[alg.merge]"/>, as indicated:</p> |
| 29 | + |
| 30 | +<blockquote> |
| 31 | +<pre> |
| 32 | +template<class InputIterator1, class InputIterator2, |
| 33 | + class OutputIterator> |
| 34 | + constexpr OutputIterator |
| 35 | + merge(InputIterator1 first1, InputIterator1 last1, |
| 36 | + InputIterator2 first2, InputIterator2 last2, |
| 37 | + OutputIterator result); |
| 38 | +[…] |
| 39 | +template<<i>execution-policy</i> Ep, <i>sized-random-access-range</i> R1, <i>sized-random-access-range</i> R2, |
| 40 | + <i>sized-random-access-range</i> OutR, class Comp = ranges::less, |
| 41 | + class Proj1 = identity, class Proj2 = identity> |
| 42 | + requires mergeable<iterator_t<R1>, iterator_t<R2>, iterator_t<OutR>, Comp, Proj1, Proj2> |
| 43 | + ranges::merge_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, borrowed_iterator_t<OutR>> |
| 44 | + ranges::merge(Ep&& exec, R1&& r1, R2&& r2, OutR&& result_r, |
| 45 | + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); |
| 46 | +</pre> |
| 47 | +<blockquote> |
| 48 | +<p> |
| 49 | +-1- Let: |
| 50 | +</p> |
| 51 | +<ul style="list-style-type: none"> |
| 52 | +<li>(1.1) — <tt><i>N</i></tt> be: […] |
| 53 | +</li> |
| 54 | +<li>(1.2) — `comp` be `less{}`, `proj1` be `identity{}`, and `proj2` be `identity{}`, |
| 55 | +for the overloads with no parameters by those names; |
| 56 | +</li> |
| 57 | +<li>(1.3) — <tt><i>E</i><del>(e1, e1)</del></tt> be <tt>bool(invoke(comp, invoke(proj2, e2), invoke(proj1, e1)))</tt>; |
| 58 | +</li> |
| 59 | +<li>(1.4) — <tt><i>K</i></tt> be the smallest integer in `[0, last1 - first1)` such that |
| 60 | +for the element `e1` in the position <tt>first1 + <i>K</i></tt> there are at least <tt>N − <i>K</i></tt> |
| 61 | +elements `e2` in `[first2, last2)` for which <tt><i>E</i><del>(e1, e1)</del></tt> holds, |
| 62 | +and be equal to `last1 - first1` if no such integer exists. |
| 63 | +</li> |
| 64 | +</ul> |
| 65 | +<p> |
| 66 | +-2- <i>Preconditions</i>: The ranges `[first1, last1)` and `[first2, last2)` are sorted with |
| 67 | +respect to `comp` and `proj1` or `proj2`, respectively. The resulting range does not overlap |
| 68 | +with either of the original ranges. |
| 69 | +<p/> |
| 70 | +-3- <i>Effects</i>: Copies the first <tt><i>K</i></tt> elements of the range `[first1, last1)` |
| 71 | +and the first <tt><i>N</i> − <i>K</i></tt> elements of the range `[first2, last2)` into the range |
| 72 | +<tt>[result, result + <i>N</i>)</tt>. If an element `a` precedes `b` in an input |
| 73 | +range, `a` is copied into the output range before `b`. If `e1` is an element of `[first1, last1)` |
| 74 | +and `e2` of `[first2, last2)`, `e2` is copied into the output range before `e1` if and only if |
| 75 | +<tt><i>E</i><del>(e1, e1)</del></tt> is `true`. |
| 76 | +</p> |
| 77 | +</blockquote> |
| 78 | +</blockquote> |
| 79 | +</li> |
| 80 | +</ol> |
| 81 | + |
| 82 | +</resolution> |
| 83 | + |
| 84 | +</issue> |
0 commit comments