|
233 | 233 | \end{codeblock} |
234 | 234 | For each iterator \tcode{i} and sentinel \tcode{s} |
235 | 235 | produced from a range \tcode{r}, |
236 | | -the semantics of \tcode{s - i} has the same type, value, and value category |
| 236 | +the semantics of \tcode{s - i} |
| 237 | +are the same as those of an expression that |
| 238 | +has the same type, value, and value category |
237 | 239 | as \tcode{ranges::distance(i, s)}. |
238 | 240 | \begin{note} |
239 | 241 | The implementation can use \tcode{ranges::distance(r)} |
|
379 | 381 | \tcode{BinaryOperation1}, |
380 | 382 | \tcode{BinaryOperation2}, |
381 | 383 | \tcode{BinaryDivideOp}, or |
382 | | -constrained by a concept that subsumes \libconcept{regular_invocable} |
| 384 | +constrained by a concept |
| 385 | +whose semantic requirements include |
| 386 | +that the type models \libconcept{regular_invocable} |
383 | 387 | and the operators used by the analogous overloads to these parallel algorithms |
384 | 388 | that are formed by an invocation |
385 | 389 | with the specified default predicate or operation (where applicable) |
|
2097 | 2101 |
|
2098 | 2102 | namespace ranges { |
2099 | 2103 | template<@\libconcept{input_iterator}@ I, @\libconcept{sentinel_for}@<I> S, class Proj = identity, |
2100 | | - class T1 = projected_value_t<I, Proj>, class T2 = T1> |
| 2104 | + class T1 = projected_value_t<I, Proj>, class T2 = iter_value_t<I>> |
2101 | 2105 | requires @\libconcept{indirectly_writable}@<I, const T2&> && |
2102 | 2106 | @\libconcept{indirect_binary_predicate}@<ranges::equal_to, projected<I, Proj>, const T1*> |
2103 | 2107 | constexpr I |
2104 | 2108 | replace(I first, S last, const T1& old_value, const T2& new_value, Proj proj = {}); |
2105 | 2109 | template<@\libconcept{input_range}@ R, class Proj = identity, |
2106 | | - class T1 = projected_value_t<iterator_t<R>, Proj>, class T2 = T1> |
| 2110 | + class T1 = projected_value_t<iterator_t<R>, Proj>, class T2 = range_value_t<R>> |
2107 | 2111 | requires @\libconcept{indirectly_writable}@<iterator_t<R>, const T2&> && |
2108 | 2112 | @\libconcept{indirect_binary_predicate}@<ranges::equal_to, |
2109 | 2113 | projected<iterator_t<R>, Proj>, const T1*> |
2110 | 2114 | constexpr borrowed_iterator_t<R> |
2111 | 2115 | replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {}); |
2112 | 2116 |
|
2113 | 2117 | template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@<I> S, |
2114 | | - class Proj = identity, class T1 = projected_value_t<I, Proj>, class T2 = T1> |
| 2118 | + class Proj = identity, |
| 2119 | + class T1 = projected_value_t<I, Proj>, class T2 = iter_value_t<I>> |
2115 | 2120 | requires @\libconcept{indirectly_writable}@<I, const T2&> && |
2116 | 2121 | @\libconcept{indirect_binary_predicate}@<ranges::equal_to, projected<I, Proj>, const T1*> |
2117 | 2122 | I replace(Ep&& exec, I first, S last, |
2118 | 2123 | const T1& old_value, const T2& new_value, Proj proj = {}); // freestanding-deleted |
2119 | 2124 | template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, |
2120 | | - class T1 = projected_value_t<iterator_t<R>, Proj>, class T2 = T1> |
| 2125 | + class T1 = projected_value_t<iterator_t<R>, Proj>, class T2 = range_value_t<R>> |
2121 | 2126 | requires @\libconcept{indirectly_writable}@<iterator_t<R>, const T2&> && |
2122 | 2127 | @\libconcept{indirect_binary_predicate}@<ranges::equal_to, |
2123 | 2128 | projected<iterator_t<R>, Proj>, const T1*> |
|
2126 | 2131 | Proj proj = {}); // freestanding-deleted |
2127 | 2132 |
|
2128 | 2133 | template<@\libconcept{input_iterator}@ I, @\libconcept{sentinel_for}@<I> S, class Proj = identity, |
2129 | | - class T = projected_value_t<I, Proj>, |
| 2134 | + class T = iter_value_t<I>, |
2130 | 2135 | @\libconcept{indirect_unary_predicate}@<projected<I, Proj>> Pred> |
2131 | 2136 | requires @\libconcept{indirectly_writable}@<I, const T&> |
2132 | 2137 | constexpr I replace_if(I first, S last, Pred pred, const T& new_value, Proj proj = {}); |
2133 | | - template<@\libconcept{input_range}@ R, class Proj = identity, class T = projected_value_t<I, Proj>, |
| 2138 | + template<@\libconcept{input_range}@ R, class Proj = identity, class T = range_value_t<R>, |
2134 | 2139 | @\libconcept{indirect_unary_predicate}@<projected<iterator_t<R>, Proj>> Pred> |
2135 | 2140 | requires @\libconcept{indirectly_writable}@<iterator_t<R>, const T&> |
2136 | 2141 | constexpr borrowed_iterator_t<R> |
2137 | 2142 | replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {}); |
2138 | 2143 |
|
2139 | 2144 | template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@<I> S, |
2140 | | - class Proj = identity, class T = projected_value_t<I, Proj>, |
| 2145 | + class Proj = identity, class T = iter_value_t<I>, |
2141 | 2146 | @\libconcept{indirect_unary_predicate}@<projected<I, Proj>> Pred> |
2142 | 2147 | requires @\libconcept{indirectly_writable}@<I, const T&> |
2143 | 2148 | I replace_if(Ep&& exec, I first, S last, Pred pred, |
2144 | 2149 | const T& new_value, Proj proj = {}); // freestanding-deleted |
2145 | 2150 | template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, |
2146 | | - class T = projected_value_t<iterator_t<R>, Proj>, |
| 2151 | + class T = range_value_t<R>, |
2147 | 2152 | @\libconcept{indirect_unary_predicate}@<projected<iterator_t<R>, Proj>> Pred> |
2148 | 2153 | requires @\libconcept{indirectly_writable}@<iterator_t<R>, const T&> |
2149 | 2154 | borrowed_iterator_t<R> |
|
7152 | 7157 | Predicate pred, const T& new_value); |
7153 | 7158 |
|
7154 | 7159 | template<@\libconcept{input_iterator}@ I, @\libconcept{sentinel_for}@<I> S, class Proj = identity, |
7155 | | - class T1 = projected_value_t<I, Proj>, class T2 = T1> |
| 7160 | + class T1 = projected_value_t<I, Proj>, class T2 = iter_value_t<I>> |
7156 | 7161 | requires @\libconcept{indirectly_writable}@<I, const T2&> && |
7157 | 7162 | @\libconcept{indirect_binary_predicate}@<ranges::equal_to, projected<I, Proj>, const T1*> |
7158 | 7163 | constexpr I |
7159 | 7164 | ranges::replace(I first, S last, const T1& old_value, const T2& new_value, Proj proj = {}); |
7160 | 7165 | template<@\libconcept{input_range}@ R, class Proj = identity, |
7161 | | - class T1 = projected_value_t<iterator_t<R>, Proj>, class T2 = T1> |
| 7166 | + class T1 = projected_value_t<iterator_t<R>, Proj>, class T2 = range_value_t<R>> |
7162 | 7167 | requires @\libconcept{indirectly_writable}@<iterator_t<R>, const T2&> && |
7163 | 7168 | @\libconcept{indirect_binary_predicate}@<ranges::equal_to, projected<iterator_t<R>, Proj>, const T1*> |
7164 | 7169 | constexpr borrowed_iterator_t<R> |
7165 | 7170 | ranges::replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {}); |
7166 | 7171 |
|
7167 | 7172 | template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@<I> S, |
7168 | | - class Proj = identity, class T1 = projected_value_t<I, Proj>, class T2 = T1> |
| 7173 | + class Proj = identity, class T1 = projected_value_t<I, Proj>, class T2 = iter_value_t<I>> |
7169 | 7174 | requires @\libconcept{indirectly_writable}@<I, const T2&> && |
7170 | 7175 | @\libconcept{indirect_binary_predicate}@<ranges::equal_to, projected<I, Proj>, const T1*> |
7171 | 7176 | I ranges::replace(Ep&& exec, I first, S last, |
7172 | 7177 | const T1& old_value, const T2& new_value, Proj proj = {}); |
7173 | 7178 | template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, |
7174 | | - class T1 = projected_value_t<iterator_t<R>, Proj>, class T2 = T1> |
| 7179 | + class T1 = projected_value_t<iterator_t<R>, Proj>, class T2 = range_value_t<R>> |
7175 | 7180 | requires @\libconcept{indirectly_writable}@<iterator_t<R>, const T2&> && |
7176 | 7181 | @\libconcept{indirect_binary_predicate}@<ranges::equal_to, |
7177 | 7182 | projected<iterator_t<R>, Proj>, const T1*> |
|
7180 | 7185 | Proj proj = {}); |
7181 | 7186 |
|
7182 | 7187 | template<@\libconcept{input_iterator}@ I, @\libconcept{sentinel_for}@<I> S, class Proj = identity, |
7183 | | - class T = projected_value_t<I, Proj>, |
| 7188 | + class T = iter_value_t<I>, |
7184 | 7189 | @\libconcept{indirect_unary_predicate}@<projected<I, Proj>> Pred> |
7185 | 7190 | requires @\libconcept{indirectly_writable}@<I, const T&> |
7186 | 7191 | constexpr I ranges::replace_if(I first, S last, Pred pred, const T& new_value, Proj proj = {}); |
7187 | | -template<@\libconcept{input_range}@ R, class Proj = identity, class T = projected_value_t<iterator_t<R>, Proj>, |
| 7192 | +template<@\libconcept{input_range}@ R, class Proj = identity, class T = range_value_t<R>, |
7188 | 7193 | @\libconcept{indirect_unary_predicate}@<projected<iterator_t<R>, Proj>> Pred> |
7189 | 7194 | requires @\libconcept{indirectly_writable}@<iterator_t<R>, const T&> |
7190 | 7195 | constexpr borrowed_iterator_t<R> |
7191 | 7196 | ranges::replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {}); |
7192 | 7197 |
|
7193 | 7198 | template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@<I> S, |
7194 | | - class Proj = identity, class T = projected_value_t<I, Proj>, |
| 7199 | + class Proj = identity, class T = iter_value_t<I>, |
7195 | 7200 | @\libconcept{indirect_unary_predicate}@<projected<I, Proj>> Pred> |
7196 | 7201 | requires @\libconcept{indirectly_writable}@<I, const T&> |
7197 | 7202 | I ranges::replace_if(Ep&& exec, I first, S last, Pred pred, |
7198 | 7203 | const T& new_value, Proj proj = {}); |
7199 | 7204 | template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, |
7200 | | - class T = projected_value_t<iterator_t<R>, Proj>, |
| 7205 | + class T = range_value_t<R>, |
7201 | 7206 | @\libconcept{indirect_unary_predicate}@<projected<iterator_t<R>, Proj>> Pred> |
7202 | 7207 | requires @\libconcept{indirectly_writable}@<iterator_t<R>, const T&> |
7203 | 7208 | borrowed_iterator_t<R> |
|
8261 | 8266 | \effects |
8262 | 8267 | Equivalent to: |
8263 | 8268 | \begin{codeblock} |
8264 | | -return ranges::rotate(std::forward<Ep>(exec), ranges::begin(r), middle, ranges::end(r)); |
| 8269 | +return ranges::rotate(std::forward<Ep>(exec), ranges::begin(r), middle, |
| 8270 | + ranges::begin(r) + ranges::distance(r)); |
8265 | 8271 | \end{codeblock} |
8266 | 8272 | \end{itemdescr} |
8267 | 8273 |
|
|
8386 | 8392 | \effects |
8387 | 8393 | Equivalent to: |
8388 | 8394 | \begin{codeblock} |
8389 | | -return ranges::rotate_copy(std::forward<Ep>(exec), ranges::begin(r), middle, ranges::end(r), |
8390 | | - ranges::begin(result_r), ranges::end(result_r)); |
| 8395 | +return ranges::rotate_copy(std::forward<Ep>(exec), ranges::begin(r), middle, |
| 8396 | + ranges::begin(r) + ranges::distance(r), |
| 8397 | + ranges::begin(result_r), |
| 8398 | + ranges::begin(result_r) + ranges::distance(result_r)); |
8391 | 8399 | \end{codeblock} |
8392 | 8400 | \end{itemdescr} |
8393 | 8401 |
|
|
9007 | 9015 | Equivalent to: |
9008 | 9016 | \begin{codeblock} |
9009 | 9017 | return ranges::partial_sort(std::forward<Ep>(exec), ranges::begin(r), middle, |
9010 | | - ranges::end(r), comp, proj); |
| 9018 | + ranges::begin(r) + ranges::distance(r), |
| 9019 | + comp, proj); |
9011 | 9020 | \end{codeblock} |
9012 | 9021 | \end{itemdescr} |
9013 | 9022 |
|
|
9391 | 9400 | \effects |
9392 | 9401 | Equivalent to: |
9393 | 9402 | \begin{codeblock} |
9394 | | -return ranges::nth_element(std::forward<Ep>(exec), ranges::begin(r), nth, ranges::end(r), |
| 9403 | +return ranges::nth_element(std::forward<Ep>(exec), ranges::begin(r), nth, |
| 9404 | + ranges::begin(r) + ranges::distance(r), |
9395 | 9405 | comp, proj); |
9396 | 9406 | \end{codeblock} |
9397 | 9407 | \end{itemdescr} |
|
9955 | 9965 | \effects |
9956 | 9966 | For each iterator \tcode{i} in \range{first}{first + $N$}, |
9957 | 9967 | copies \tcode{*i} to the output range \range{out_true}{last_true} |
9958 | | -if \tcode{$E(\tcode{*i})$} is \tcode{true}, or |
| 9968 | +if $E(\tcode{*i})$ is \tcode{true}, or |
9959 | 9969 | to the output range \range{out_false}{last_false} otherwise. |
9960 | 9970 |
|
9961 | 9971 | \pnum |
9962 | 9972 | \returns |
9963 | | -Let \tcode{o1} be the iterator past the last copied element |
9964 | | -in the output range \range{out_true}{last_true}, |
9965 | | -and \tcode{o2} be the iterator past the last copied element |
9966 | | -in the output range \range{out_false}{last_false}. |
| 9973 | +Let $Q$ be the number of elements copied |
| 9974 | +into the output range \range{out_true}{last_true}, |
| 9975 | +and $V$ be the number of elements copied |
| 9976 | +into the output range \range{out_false}{last_false}. |
9967 | 9977 | Returns: |
9968 | 9978 | \begin{itemize} |
9969 | | -\item \tcode{\{o1, o2\}} for the overloads in namespace \tcode{std}. |
9970 | | -\item \tcode{\{first + $N$, o1, o2\}} for the overloads in namespace \tcode{ranges}. |
| 9979 | +\item \tcode{\{out_true + $Q$, out_false + $V$\}} for the overloads in namespace \tcode{std}. |
| 9980 | +\item \tcode{\{first + $N$, out_true + $Q$, out_false + $V$\}} for the overloads in namespace \tcode{ranges}. |
9971 | 9981 | \end{itemize} |
9972 | 9982 |
|
9973 | 9983 | \pnum |
@@ -10097,12 +10107,12 @@ |
10097 | 10107 | \tcode{proj2} be \tcode{identity\{\}}, |
10098 | 10108 | for the overloads with no parameters by those names; |
10099 | 10109 | \item |
10100 | | - $E(\tcode{e1}, \tcode{e1})$ be \tcode{bool(invoke(comp, invoke(proj2, e2), invoke(proj1, e1)))}; |
| 10110 | + $E$ be \tcode{bool(invoke(comp, invoke(proj2, e2), invoke(proj1, e1)))}; |
10101 | 10111 | \item |
10102 | 10112 | $K$ be the smallest integer in \range{0}{last1 - first1} |
10103 | 10113 | such that for the element \tcode{e1} in the position \tcode{first1 + $K$} |
10104 | 10114 | there are at least $N - K$ elements \tcode{e2} |
10105 | | - in \range{first2}{last2} for which $E(\tcode{e1}, \tcode{e1})$ holds, |
| 10115 | + in \range{first2}{last2} for which $E$ holds, |
10106 | 10116 | and be equal to \tcode{last1 - first1} |
10107 | 10117 | if no such integer exists. |
10108 | 10118 | \begin{note} |
|
10127 | 10137 | If \tcode{e1} is an element of \range{first1}{last1} and |
10128 | 10138 | \tcode{e2} of \range{first2}{last2}, |
10129 | 10139 | \tcode{e2} is copied into the output range before \tcode{e1} |
10130 | | -if and only if $E(\tcode{e1}, \tcode{e1})$ is \tcode{true}. |
| 10140 | +if and only if $E$ is \tcode{true}. |
10131 | 10141 |
|
10132 | 10142 | \pnum |
10133 | 10143 | \returns |
|
10264 | 10274 | Equivalent to: |
10265 | 10275 | \begin{codeblock} |
10266 | 10276 | return ranges::inplace_merge(std::forward<Ep>(exec), ranges::begin(r), middle, |
10267 | | - ranges::end(r), comp, proj); |
| 10277 | + ranges::begin(r) + ranges::distance(r), |
| 10278 | + comp, proj); |
10268 | 10279 | \end{codeblock} |
10269 | 10280 | \end{itemdescr} |
10270 | 10281 |
|
|
13541 | 13552 | } |
13542 | 13553 |
|
13543 | 13554 | template<class I> |
13544 | | - decltype(auto) @\exposid{deref-move}@(I& it) { |
| 13555 | + constexpr decltype(auto) @\exposid{deref-move}@(I& it) { |
13545 | 13556 | if constexpr (is_lvalue_reference_v<decltype(*it)>) |
13546 | 13557 | return std::move(*it); |
13547 | 13558 | else |
|
0 commit comments