|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4297" status="New"> |
| 5 | +<title>Missing `permutable` constraint for iterator overloads in Parallel Range Algorithms</title> |
| 6 | +<section><sref ref="[algorithm.syn]"/><sref ref="[alg.remove]"/><sref ref="[alg.partitions]"/></section> |
| 7 | +<submitter>Ruslan Arutyunyan</submitter> |
| 8 | +<date>27 Jun 2025</date> |
| 9 | +<priority>99</priority> |
| 10 | + |
| 11 | +<discussion> |
| 12 | +<p> |
| 13 | +The <paper num="P3179R9"/>: Parallel Range Algorithms paper was accepted to C++ working draft for C++ 26. |
| 14 | +Unfortunately, there is an oversight for three algorithms — `remove`, `remove_if` and `partition` — |
| 15 | +where the `permutable` constraint is missing. This applies to "Iterator and Sentinel" overloads only. The |
| 16 | +issue exists in <sref ref="[algorithm.syn]"/> as well as in per-algorithm sections: |
| 17 | +<sref ref="[alg.partitions]"/> and <sref ref="[alg.remove]"/>. |
| 18 | +</p> |
| 19 | +</discussion> |
| 20 | + |
| 21 | +<resolution> |
| 22 | +<p> |
| 23 | +This wording is relative to this |
| 24 | +<a href="https://github.com/cplusplus/draft/actions/runs/16433597877/artifacts/3583518547">CD preview draft</a>. |
| 25 | +</p> |
| 26 | + |
| 27 | + |
| 28 | +<ol> |
| 29 | + |
| 30 | +<li><p>Modify <sref ref="[algorithm.syn]"/>, header <tt><algorithm></tt>, as indicated:</p> |
| 31 | + |
| 32 | +<blockquote> |
| 33 | +<pre> |
| 34 | +[…] |
| 35 | +template<<i>execution-policy</i> Ep, random_access_iterator I, sized_sentinel_for<I> S, |
| 36 | + class Proj = identity, class T = projected_value_t<I, Proj>> |
| 37 | + requires <ins>permutable<I> &&</ins> |
| 38 | + indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*> |
| 39 | + subrange<I> remove(Ep& exec, I first, S last, const T& value, |
| 40 | + Proj proj = {}); <i>// freestanding-deleted</i> |
| 41 | +template<<i>execution-policy</i> Ep, <i>sized-random-access-range</i> R, class Proj = identity, |
| 42 | + class T = projected_value_t<iterator_t<R>, Proj>> |
| 43 | + requires permutable<iterator_t<R>> && |
| 44 | + indirect_binary_predicate<ranges::equal_to, |
| 45 | + projected<iterator_t<R>, Proj>, const T*> |
| 46 | + borrowed_subrange_t<R> |
| 47 | + remove(Ep&& exec, R&& r, const T& value, Proj proj = {}); <i>// freestanding-deleted</i> |
| 48 | +[…] |
| 49 | +template<<i>execution-policy</i> Ep, random_access_iterator I, sized_sentinel_for<I> S, |
| 50 | + class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred> |
| 51 | + <ins>requires permutable<I></ins> |
| 52 | + subrange<I> |
| 53 | + remove_if(Ep& exec, I first, S last, Pred pred, Proj proj = {}); <i>// freestanding-deleted</i> |
| 54 | +template<<i>execution-policy</i> Ep, <i>sized-random-access-range</i> R, class Proj = identity, |
| 55 | + indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> |
| 56 | + requires permutable<iterator_t<R>> |
| 57 | + borrowed_subrange_t<R> |
| 58 | + remove_if(Ep& exec, R& r, Pred pred, Proj proj = {}); <i>// freestanding-deleted</i> |
| 59 | +[…] |
| 60 | +template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S, |
| 61 | + class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred> |
| 62 | + <ins>requires permutable<I></ins> |
| 63 | + subrange<I> |
| 64 | + partition(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); <i>// freestanding-deleted</i> |
| 65 | +template<<i>execution-policy</i> Ep, <i>sized-random-access-range</i> R, class Proj = identity, |
| 66 | + indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> |
| 67 | + requires permutable<iterator_t<R>> |
| 68 | + borrowed_subrange_t<R> |
| 69 | + partition(Ep&& exec, R&& r, Pred pred, Proj proj = {}); <i>// freestanding-deleted</i> |
| 70 | +[…] |
| 71 | +</pre> |
| 72 | +</blockquote> |
| 73 | +</li> |
| 74 | + |
| 75 | + |
| 76 | +<li><p>Modify <sref ref="[alg.remove]"/> as indicated:</p> |
| 77 | + |
| 78 | +<blockquote> |
| 79 | +<pre> |
| 80 | +[…] |
| 81 | +template<<i>execution-policy</i> Ep, random_access_iterator I, sized_sentinel_for<I> S, |
| 82 | + class Proj = identity, class T = projected_value_t<I, Proj>> |
| 83 | + requires <ins>permutable<I> &&</ins> |
| 84 | + indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*> |
| 85 | + subrange<I> |
| 86 | + ranges::remove(Ep& exec, I first, S last, const T& value, Proj proj = {}); |
| 87 | +template<<i>execution-policy</i> Ep, <i>sized-random-access-range</i> R, class Proj = identity, |
| 88 | + class T = projected_value_t<iterator_t<R>, Proj>> |
| 89 | + requires permutable<iterator_t<R>> && |
| 90 | + indirect_binary_predicate<ranges::equal_to, |
| 91 | + projected<iterator_t<R>, Proj>, const T*> |
| 92 | + borrowed_subrange_t<R> |
| 93 | + ranges::remove(Ep&& exec, R&& r, const T& value, Proj proj = {}); |
| 94 | +[…] |
| 95 | +template<<i>execution-policy</i> Ep, random_access_iterator I, sized_sentinel_for<I> S, |
| 96 | + class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred> |
| 97 | + <ins>requires permutable<I></ins> |
| 98 | + subrange<I> |
| 99 | + ranges::remove_if(Ep& exec, I first, S last, Pred pred, Proj proj = {}); |
| 100 | +template<<i>execution-policy</i> Ep, <i>sized-random-access-range</i> R, class Proj = identity, |
| 101 | + indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> |
| 102 | + requires permutable<iterator_t<R>> |
| 103 | + borrowed_subrange_t<R> |
| 104 | + ranges::remove_if(Ep& exec, R& r, Pred pred, Proj proj = {}); |
| 105 | +</pre> |
| 106 | +<blockquote> |
| 107 | +<p> |
| 108 | +-1- Let <tt><i>E</i></tt> be […] |
| 109 | +</p> |
| 110 | +</blockquote> |
| 111 | +</blockquote> |
| 112 | +</li> |
| 113 | + |
| 114 | + |
| 115 | +<li><p>Modify <sref ref="[alg.partitions]"/> as indicated:</p> |
| 116 | + |
| 117 | +<blockquote> |
| 118 | +<pre> |
| 119 | +[…] |
| 120 | +template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S, |
| 121 | + class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred> |
| 122 | + <ins>requires permutable<I></ins> |
| 123 | + subrange<I> |
| 124 | + ranges::partition(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); |
| 125 | +template<<i>execution-policy</i> Ep, <i>sized-random-access-range</i> R, class Proj = identity, |
| 126 | + indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> |
| 127 | + requires permutable<iterator_t<R>> |
| 128 | + borrowed_subrange_t<R> |
| 129 | + ranges::partition(Ep&& exec, R&& r, Pred pred, Proj proj = {}); |
| 130 | +</pre> |
| 131 | +<blockquote> |
| 132 | +<p> |
| 133 | +-1- Let `proj` be `identity{}` for the overloads with no parameter named `proj`. |
| 134 | +</p> |
| 135 | +</blockquote> |
| 136 | +</blockquote> |
| 137 | +</li> |
| 138 | + |
| 139 | +</ol> |
| 140 | +</resolution> |
| 141 | + |
| 142 | +</issue> |
0 commit comments