- tmp/tmpxjoga6l8/{from.md → to.md} +585 -123
tmp/tmpxjoga6l8/{from.md → to.md}
RENAMED
|
@@ -31,25 +31,43 @@ range \[`result`, `result + `N) starting from `first` and proceeding to
|
|
| 31 |
|
| 32 |
*Complexity:* Exactly N assignments.
|
| 33 |
|
| 34 |
``` cpp
|
| 35 |
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
|
| 36 |
-
ForwardIterator2 copy(ExecutionPolicy&&
|
| 37 |
ForwardIterator1 first, ForwardIterator1 last,
|
| 38 |
ForwardIterator2 result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
```
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
*Preconditions:* The ranges \[`first`, `last`) and \[`result`,
|
| 42 |
-
`result +
|
| 43 |
|
| 44 |
-
*Effects:* Copies elements in the range \[`first`, `
|
| 45 |
-
range \[`result`, `result +
|
| 46 |
-
|
| 47 |
|
| 48 |
-
*Returns:*
|
| 49 |
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
``` cpp
|
| 53 |
template<class InputIterator, class Size, class OutputIterator>
|
| 54 |
constexpr OutputIterator copy_n(InputIterator first, Size n,
|
| 55 |
OutputIterator result);
|
|
@@ -60,13 +78,24 @@ template<class ExecutionPolicy, class ForwardIterator1, class Size, class Forwar
|
|
| 60 |
|
| 61 |
template<input_iterator I, weakly_incrementable O>
|
| 62 |
requires indirectly_copyable<I, O>
|
| 63 |
constexpr ranges::copy_n_result<I, O>
|
| 64 |
ranges::copy_n(I first, iter_difference_t<I> n, O result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
```
|
| 66 |
|
| 67 |
-
Let
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
*Mandates:* The type `Size` is convertible to an integral
|
| 70 |
type [[conv.integral]], [[class.conv]].
|
| 71 |
|
| 72 |
*Effects:* For each non-negative integer i < N, performs
|
|
@@ -97,38 +126,66 @@ template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj
|
|
| 97 |
template<input_range R, weakly_incrementable O, class Proj = identity,
|
| 98 |
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
|
| 99 |
requires indirectly_copyable<iterator_t<R>, O>
|
| 100 |
constexpr ranges::copy_if_result<borrowed_iterator_t<R>, O>
|
| 101 |
ranges::copy_if(R&& r, O result, Pred pred, Proj proj = {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
```
|
| 103 |
|
| 104 |
-
Let E be:
|
| 105 |
|
| 106 |
- `bool(pred(*i))` for the overloads in namespace `std`;
|
| 107 |
- `bool(invoke(pred, invoke(proj, *i)))` for the overloads in namespace
|
| 108 |
-
`ranges`
|
| 109 |
|
| 110 |
-
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
*Preconditions:* The ranges \[`first`, `last`) and \[`result`,
|
| 114 |
-
`result +
|
| 115 |
|
| 116 |
-
[*Note 1*: For the overload
|
| 117 |
-
performance cost if
|
| 118 |
-
not
|
| 119 |
-
([[cpp17.moveconstructible]])
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
-
*Effects:* Copies
|
| 122 |
-
the range \[`first`, `last`) for which E is `true`
|
|
|
|
| 123 |
|
| 124 |
*Returns:*
|
| 125 |
|
| 126 |
- `result + `N for the overloads in namespace `std`.
|
| 127 |
-
- `{last, result + `N`}` for the overloads in namespace `ranges`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
-
*Complexity:*
|
| 130 |
predicate and any projection.
|
| 131 |
|
| 132 |
*Remarks:* Stable [[algorithm.stable]].
|
| 133 |
|
| 134 |
``` cpp
|
|
@@ -181,11 +238,11 @@ template<input_range R, weakly_incrementable O>
|
|
| 181 |
requires indirectly_movable<iterator_t<R>, O>
|
| 182 |
constexpr ranges::move_result<borrowed_iterator_t<R>, O>
|
| 183 |
ranges::move(R&& r, O result);
|
| 184 |
```
|
| 185 |
|
| 186 |
-
Let E be
|
| 187 |
|
| 188 |
- `std::move(*(first + `n`))` for the overload in namespace `std`;
|
| 189 |
- `ranges::iter_move(first + `n`)` for the overloads in namespace
|
| 190 |
`ranges`.
|
| 191 |
|
|
@@ -194,36 +251,58 @@ Let N be `last - first`.
|
|
| 194 |
*Preconditions:* `result` is not in the range \[`first`, `last`).
|
| 195 |
|
| 196 |
*Effects:* Moves elements in the range \[`first`, `last`) into the range
|
| 197 |
\[`result`, `result + `N) starting from `first` and proceeding to
|
| 198 |
`last`. For each non-negative integer n < N, performs
|
| 199 |
-
`*(result + `n`) = `E.
|
| 200 |
|
| 201 |
*Returns:*
|
| 202 |
|
| 203 |
- `result + `N for the overload in namespace `std`.
|
| 204 |
- `{last, result + `N`}` for the overloads in namespace `ranges`.
|
| 205 |
|
| 206 |
*Complexity:* Exactly N assignments.
|
| 207 |
|
| 208 |
``` cpp
|
| 209 |
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
|
| 210 |
-
ForwardIterator2 move(ExecutionPolicy&&
|
| 211 |
ForwardIterator1 first, ForwardIterator1 last,
|
| 212 |
ForwardIterator2 result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
```
|
| 214 |
|
| 215 |
-
Let
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
|
| 217 |
*Preconditions:* The ranges \[`first`, `last`) and \[`result`,
|
| 218 |
`result + `N) do not overlap.
|
| 219 |
|
| 220 |
-
*Effects:* Moves elements in the range \[`first`, `
|
| 221 |
-
\[`result`, `result + `N). For each non-negative integer n < N,
|
| 222 |
-
`*(result + `n`) =
|
| 223 |
|
| 224 |
-
*Returns:*
|
|
|
|
|
|
|
|
|
|
| 225 |
|
| 226 |
*Complexity:* Exactly N assignments.
|
| 227 |
|
| 228 |
``` cpp
|
| 229 |
template<class BidirectionalIterator1, class BidirectionalIterator2>
|
|
@@ -239,11 +318,11 @@ template<bidirectional_range R, bidirectional_iterator I>
|
|
| 239 |
requires indirectly_movable<iterator_t<R>, I>
|
| 240 |
constexpr ranges::move_backward_result<borrowed_iterator_t<R>, I>
|
| 241 |
ranges::move_backward(R&& r, I result);
|
| 242 |
```
|
| 243 |
|
| 244 |
-
Let E be
|
| 245 |
|
| 246 |
- `std::move(*(last - `n`))` for the overload in namespace `std`;
|
| 247 |
- `ranges::iter_move(last - `n`)` for the overloads in namespace
|
| 248 |
`ranges`.
|
| 249 |
|
|
@@ -253,11 +332,11 @@ Let N be `last - first`.
|
|
| 253 |
|
| 254 |
*Effects:* Moves elements in the range \[`first`, `last`) into the range
|
| 255 |
\[`result - `N, `result`) starting from `last - 1` and proceeding to
|
| 256 |
`first`.[^3]
|
| 257 |
|
| 258 |
-
For each positive integer n ≤ N, performs `*(result - `n`) = `E.
|
| 259 |
|
| 260 |
*Returns:*
|
| 261 |
|
| 262 |
- `result - `N for the overload in namespace `std`.
|
| 263 |
- `{last, result - `N`}` for the overloads in namespace `ranges`.
|
|
@@ -283,16 +362,26 @@ template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for
|
|
| 283 |
ranges::swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
|
| 284 |
template<input_range R1, input_range R2>
|
| 285 |
requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
|
| 286 |
constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
|
| 287 |
ranges::swap_ranges(R1&& r1, R2&& r2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
```
|
| 289 |
|
| 290 |
Let:
|
| 291 |
|
| 292 |
-
- `last2` be `first2 + (last1 - first1)` for the overloads
|
| 293 |
-
parameter named `last2`;
|
| 294 |
- M be min(`last1 - first1`, `last2 - first2`).
|
| 295 |
|
| 296 |
*Preconditions:* The two ranges \[`first1`, `last1`) and \[`first2`,
|
| 297 |
`last2`) do not overlap. For the overloads in namespace `std`,
|
| 298 |
`*(first1 + `n`)` is swappable with [[swappable.requirements]]
|
|
@@ -360,10 +449,25 @@ template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
|
|
| 360 |
template<input_range R, weakly_incrementable O, copy_constructible F,
|
| 361 |
class Proj = identity>
|
| 362 |
requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R>, Proj>>>
|
| 363 |
constexpr ranges::unary_transform_result<borrowed_iterator_t<R>, O>
|
| 364 |
ranges::transform(R&& r, O result, F op, Proj proj = {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
|
| 366 |
weakly_incrementable O, copy_constructible F, class Proj1 = identity,
|
| 367 |
class Proj2 = identity>
|
| 368 |
requires indirectly_writable<O, indirect_result_t<F&, projected<I1, Proj1>,
|
| 369 |
projected<I2, Proj2>>>
|
|
@@ -375,104 +479,165 @@ template<input_range R1, input_range R2, weakly_incrementable O,
|
|
| 375 |
requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R1>, Proj1>,
|
| 376 |
projected<iterator_t<R2>, Proj2>>>
|
| 377 |
constexpr ranges::binary_transform_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
|
| 378 |
ranges::transform(R1&& r1, R2&& r2, O result,
|
| 379 |
F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 380 |
```
|
| 381 |
|
| 382 |
Let:
|
| 383 |
|
| 384 |
-
- `last2` be `first2 + (last1 - first1)` for the overloads
|
| 385 |
-
parameter `first2` but no parameter `last2`;
|
| 386 |
-
-
|
| 387 |
min(`last1 - first1`, `last2 - first2`) for binary transforms;
|
| 388 |
-
-
|
|
|
|
|
|
|
|
|
|
| 389 |
- `op(*(first1 + (i - result)))` for unary transforms defined in
|
| 390 |
namespace `std`;
|
| 391 |
- `binary_op(*(first1 + (i - result)), *(first2 + (i - result)))` for
|
| 392 |
binary transforms defined in namespace `std`;
|
| 393 |
- `invoke(op, invoke(proj, *(first1 + (i - result))))` for unary
|
| 394 |
transforms defined in namespace `ranges`;
|
| 395 |
- `invoke(binary_op, invoke(proj1, *(first1 + (i - result))), invoke(proj2,*(first2 + (i - result))))`
|
| 396 |
for binary transforms defined in namespace `ranges`.
|
| 397 |
|
| 398 |
-
*Preconditions:* `op` and `binary_op`
|
| 399 |
-
|
|
|
|
|
|
|
| 400 |
|
| 401 |
- \[`first1`, `first1 + `N\],
|
| 402 |
- \[`first2`, `first2 + `N\], and
|
| 403 |
- \[`result`, `result + `N\].[^4]
|
| 404 |
|
| 405 |
*Effects:* Assigns through every iterator `i` in the range \[`result`,
|
| 406 |
-
`result + `N) a new corresponding value equal to E.
|
| 407 |
|
| 408 |
*Returns:*
|
| 409 |
|
| 410 |
- `result + `N for the overloads defined in namespace `std`.
|
| 411 |
- `{first1 + `N`, result + `N`}` for unary transforms defined in
|
| 412 |
namespace `ranges`.
|
| 413 |
- `{first1 + `N`, first2 + `N`, result + `N`}` for binary transforms
|
| 414 |
defined in namespace `ranges`.
|
| 415 |
|
| 416 |
*Complexity:* Exactly N applications of `op` or `binary_op`, and any
|
| 417 |
-
projections. This requirement also applies to the
|
| 418 |
-
|
| 419 |
|
| 420 |
*Remarks:* `result` may be equal to `first1` or `first2`.
|
| 421 |
|
| 422 |
### Replace <a id="alg.replace">[[alg.replace]]</a>
|
| 423 |
|
| 424 |
``` cpp
|
| 425 |
-
template<class ForwardIterator, class T>
|
| 426 |
constexpr void replace(ForwardIterator first, ForwardIterator last,
|
| 427 |
const T& old_value, const T& new_value);
|
| 428 |
-
template<class ExecutionPolicy, class ForwardIterator,
|
|
|
|
| 429 |
void replace(ExecutionPolicy&& exec,
|
| 430 |
ForwardIterator first, ForwardIterator last,
|
| 431 |
const T& old_value, const T& new_value);
|
| 432 |
|
| 433 |
-
template<class ForwardIterator, class Predicate,
|
|
|
|
| 434 |
constexpr void replace_if(ForwardIterator first, ForwardIterator last,
|
| 435 |
Predicate pred, const T& new_value);
|
| 436 |
-
template<class ExecutionPolicy, class ForwardIterator, class Predicate,
|
|
|
|
| 437 |
void replace_if(ExecutionPolicy&& exec,
|
| 438 |
ForwardIterator first, ForwardIterator last,
|
| 439 |
Predicate pred, const T& new_value);
|
| 440 |
|
| 441 |
-
template<input_iterator I, sentinel_for<I> S, class
|
|
|
|
| 442 |
requires indirectly_writable<I, const T2&> &&
|
| 443 |
indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
|
| 444 |
constexpr I
|
| 445 |
ranges::replace(I first, S last, const T1& old_value, const T2& new_value, Proj proj = {});
|
| 446 |
-
template<input_range R, class
|
|
|
|
| 447 |
requires indirectly_writable<iterator_t<R>, const T2&> &&
|
| 448 |
indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T1*>
|
| 449 |
constexpr borrowed_iterator_t<R>
|
| 450 |
ranges::replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {});
|
| 451 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 452 |
indirect_unary_predicate<projected<I, Proj>> Pred>
|
| 453 |
requires indirectly_writable<I, const T&>
|
| 454 |
constexpr I ranges::replace_if(I first, S last, Pred pred, const T& new_value, Proj proj = {});
|
| 455 |
-
template<input_range R, class
|
| 456 |
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
|
| 457 |
requires indirectly_writable<iterator_t<R>, const T&>
|
| 458 |
constexpr borrowed_iterator_t<R>
|
| 459 |
ranges::replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 460 |
```
|
| 461 |
|
| 462 |
-
Let E be
|
| 463 |
|
| 464 |
- `bool(*i == old_value)` for `replace`;
|
| 465 |
- `bool(pred(*i))` for `replace_if`;
|
| 466 |
- `bool(invoke(proj, *i) == old_value)` for `ranges::replace`;
|
| 467 |
- `bool(invoke(pred, invoke(proj, *i)))` for `ranges::replace_if`.
|
| 468 |
|
| 469 |
*Mandates:* `new_value` is writable [[iterator.requirements.general]] to
|
| 470 |
`first`.
|
| 471 |
|
| 472 |
*Effects:* Substitutes elements referred by the iterator `i` in the
|
| 473 |
-
range \[`first`, `last`) with `new_value`, when E is `true`.
|
| 474 |
|
| 475 |
*Returns:* `last` for the overloads in namespace `ranges`.
|
| 476 |
|
| 477 |
*Complexity:* Exactly `last - first` applications of the corresponding
|
| 478 |
predicate and any projection.
|
|
@@ -501,90 +666,150 @@ template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
|
|
| 501 |
replace_copy_if(ExecutionPolicy&& exec,
|
| 502 |
ForwardIterator1 first, ForwardIterator1 last,
|
| 503 |
ForwardIterator2 result,
|
| 504 |
Predicate pred, const T& new_value);
|
| 505 |
|
| 506 |
-
template<input_iterator I, sentinel_for<I> S, class
|
| 507 |
-
class Proj = identity>
|
| 508 |
requires indirectly_copyable<I, O> &&
|
| 509 |
-
indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
|
|
|
|
| 510 |
constexpr ranges::replace_copy_result<I, O>
|
| 511 |
ranges::replace_copy(I first, S last, O result, const T1& old_value, const T2& new_value,
|
| 512 |
Proj proj = {});
|
| 513 |
-
template<input_range R, class
|
| 514 |
-
class Proj =
|
| 515 |
requires indirectly_copyable<iterator_t<R>, O> &&
|
| 516 |
indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T1*>
|
|
|
|
| 517 |
constexpr ranges::replace_copy_result<borrowed_iterator_t<R>, O>
|
| 518 |
ranges::replace_copy(R&& r, O result, const T1& old_value, const T2& new_value,
|
| 519 |
Proj proj = {});
|
| 520 |
|
| 521 |
-
template<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 522 |
class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
|
| 523 |
-
requires indirectly_copyable<I, O>
|
| 524 |
constexpr ranges::replace_copy_if_result<I, O>
|
| 525 |
ranges::replace_copy_if(I first, S last, O result, Pred pred, const T& new_value,
|
| 526 |
Proj proj = {});
|
| 527 |
-
template<input_range R, class
|
| 528 |
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
|
| 529 |
-
requires indirectly_copyable<iterator_t<R>, O>
|
| 530 |
constexpr ranges::replace_copy_if_result<borrowed_iterator_t<R>, O>
|
| 531 |
ranges::replace_copy_if(R&& r, O result, Pred pred, const T& new_value,
|
| 532 |
Proj proj = {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 533 |
```
|
| 534 |
|
| 535 |
-
Let E be
|
| 536 |
|
| 537 |
- `bool(*(first + (i - result)) == old_value)` for `replace_copy`;
|
| 538 |
- `bool(pred(*(first + (i - result))))` for `replace_copy_if`;
|
| 539 |
- `bool(invoke(proj, *(first + (i - result))) == old_value)` for
|
| 540 |
`ranges::replace_copy`;
|
| 541 |
- `bool(invoke(pred, invoke(proj, *(first + (i - result)))))` for
|
| 542 |
`ranges::replace_copy_if`.
|
| 543 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 544 |
*Mandates:* The results of the expressions `*first` and `new_value` are
|
| 545 |
writable [[iterator.requirements.general]] to `result`.
|
| 546 |
|
| 547 |
*Preconditions:* The ranges \[`first`, `last`) and \[`result`,
|
| 548 |
-
`result +
|
| 549 |
|
| 550 |
*Effects:* Assigns through every iterator `i` in the range \[`result`,
|
| 551 |
-
`result +
|
| 552 |
|
| 553 |
-
- `new_value` if E is `true` or
|
| 554 |
- `*(first + (i - result))` otherwise.
|
| 555 |
|
| 556 |
*Returns:*
|
| 557 |
|
| 558 |
-
- `result +
|
| 559 |
-
- `{
|
| 560 |
-
`ranges`.
|
| 561 |
|
| 562 |
-
*Complexity:* Exactly
|
| 563 |
-
|
| 564 |
|
| 565 |
### Fill <a id="alg.fill">[[alg.fill]]</a>
|
| 566 |
|
| 567 |
``` cpp
|
| 568 |
-
template<class ForwardIterator, class T>
|
| 569 |
constexpr void fill(ForwardIterator first, ForwardIterator last, const T& value);
|
| 570 |
-
template<class ExecutionPolicy, class ForwardIterator,
|
|
|
|
| 571 |
void fill(ExecutionPolicy&& exec,
|
| 572 |
ForwardIterator first, ForwardIterator last, const T& value);
|
| 573 |
|
| 574 |
-
template<class OutputIterator, class Size, class T>
|
| 575 |
constexpr OutputIterator fill_n(OutputIterator first, Size n, const T& value);
|
| 576 |
-
template<class ExecutionPolicy, class ForwardIterator, class Size,
|
|
|
|
| 577 |
ForwardIterator fill_n(ExecutionPolicy&& exec,
|
| 578 |
ForwardIterator first, Size n, const T& value);
|
| 579 |
|
| 580 |
-
template<class
|
|
|
|
| 581 |
constexpr O ranges::fill(O first, S last, const T& value);
|
| 582 |
-
template<class
|
|
|
|
| 583 |
constexpr borrowed_iterator_t<R> ranges::fill(R&& r, const T& value);
|
| 584 |
-
template<class
|
|
|
|
| 585 |
constexpr O ranges::fill_n(O first, iter_difference_t<O> n, const T& value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 586 |
```
|
| 587 |
|
| 588 |
Let N be max(0, `n`) for the `fill_n` algorithms, and `last - first` for
|
| 589 |
the `fill` algorithms.
|
| 590 |
|
|
@@ -624,10 +849,21 @@ template<class R, copy_constructible F>
|
|
| 624 |
requires invocable<F&> && output_range<R, invoke_result_t<F&>>
|
| 625 |
constexpr borrowed_iterator_t<R> ranges::generate(R&& r, F gen);
|
| 626 |
template<input_or_output_iterator O, copy_constructible F>
|
| 627 |
requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
|
| 628 |
constexpr O ranges::generate_n(O first, iter_difference_t<O> n, F gen);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 629 |
```
|
| 630 |
|
| 631 |
Let N be max(0, `n`) for the `generate_n` algorithms, and `last - first`
|
| 632 |
for the `generate` algorithms.
|
| 633 |
|
|
@@ -639,17 +875,21 @@ through each iterator in the range \[`first`, `first + `N).
|
|
| 639 |
|
| 640 |
*Returns:* `first + `N.
|
| 641 |
|
| 642 |
*Complexity:* Exactly N evaluations of `gen()` and assignments.
|
| 643 |
|
|
|
|
|
|
|
|
|
|
| 644 |
### Remove <a id="alg.remove">[[alg.remove]]</a>
|
| 645 |
|
| 646 |
``` cpp
|
| 647 |
-
template<class ForwardIterator, class T>
|
| 648 |
constexpr ForwardIterator remove(ForwardIterator first, ForwardIterator last,
|
| 649 |
const T& value);
|
| 650 |
-
template<class ExecutionPolicy, class ForwardIterator,
|
|
|
|
| 651 |
ForwardIterator remove(ExecutionPolicy&& exec,
|
| 652 |
ForwardIterator first, ForwardIterator last,
|
| 653 |
const T& value);
|
| 654 |
|
| 655 |
template<class ForwardIterator, class Predicate>
|
|
@@ -658,26 +898,52 @@ template<class ForwardIterator, class Predicate>
|
|
| 658 |
template<class ExecutionPolicy, class ForwardIterator, class Predicate>
|
| 659 |
ForwardIterator remove_if(ExecutionPolicy&& exec,
|
| 660 |
ForwardIterator first, ForwardIterator last,
|
| 661 |
Predicate pred);
|
| 662 |
|
| 663 |
-
template<permutable I, sentinel_for<I> S, class
|
|
|
|
| 664 |
requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
|
| 665 |
constexpr subrange<I> ranges::remove(I first, S last, const T& value, Proj proj = {});
|
| 666 |
-
template<forward_range R, class
|
|
|
|
| 667 |
requires permutable<iterator_t<R>> &&
|
| 668 |
indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
|
| 669 |
constexpr borrowed_subrange_t<R>
|
| 670 |
ranges::remove(R&& r, const T& value, Proj proj = {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 671 |
template<permutable I, sentinel_for<I> S, class Proj = identity,
|
| 672 |
indirect_unary_predicate<projected<I, Proj>> Pred>
|
| 673 |
constexpr subrange<I> ranges::remove_if(I first, S last, Pred pred, Proj proj = {});
|
| 674 |
template<forward_range R, class Proj = identity,
|
| 675 |
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
|
| 676 |
requires permutable<iterator_t<R>>
|
| 677 |
constexpr borrowed_subrange_t<R>
|
| 678 |
ranges::remove_if(R&& r, Pred pred, Proj proj = {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 679 |
```
|
| 680 |
|
| 681 |
Let E be
|
| 682 |
|
| 683 |
- `bool(*i == value)` for `remove`;
|
|
@@ -706,16 +972,17 @@ predicate and any projection.
|
|
| 706 |
the returned value, has a valid but unspecified state, because the
|
| 707 |
algorithms can eliminate elements by moving from elements that were
|
| 708 |
originally in that range. — *end note*]
|
| 709 |
|
| 710 |
``` cpp
|
| 711 |
-
template<class InputIterator, class OutputIterator,
|
|
|
|
| 712 |
constexpr OutputIterator
|
| 713 |
remove_copy(InputIterator first, InputIterator last,
|
| 714 |
OutputIterator result, const T& value);
|
| 715 |
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
|
| 716 |
-
class T>
|
| 717 |
ForwardIterator2
|
| 718 |
remove_copy(ExecutionPolicy&& exec,
|
| 719 |
ForwardIterator1 first, ForwardIterator1 last,
|
| 720 |
ForwardIterator2 result, const T& value);
|
| 721 |
|
|
@@ -728,63 +995,109 @@ template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
|
|
| 728 |
ForwardIterator2
|
| 729 |
remove_copy_if(ExecutionPolicy&& exec,
|
| 730 |
ForwardIterator1 first, ForwardIterator1 last,
|
| 731 |
ForwardIterator2 result, Predicate pred);
|
| 732 |
|
| 733 |
-
template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
|
| 734 |
-
class Proj = identity>
|
| 735 |
requires indirectly_copyable<I, O> &&
|
| 736 |
indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
|
| 737 |
constexpr ranges::remove_copy_result<I, O>
|
| 738 |
ranges::remove_copy(I first, S last, O result, const T& value, Proj proj = {});
|
| 739 |
-
template<input_range R, weakly_incrementable O, class
|
|
|
|
| 740 |
requires indirectly_copyable<iterator_t<R>, O> &&
|
| 741 |
indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
|
| 742 |
constexpr ranges::remove_copy_result<borrowed_iterator_t<R>, O>
|
| 743 |
ranges::remove_copy(R&& r, O result, const T& value, Proj proj = {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 744 |
template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
|
| 745 |
class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
|
| 746 |
requires indirectly_copyable<I, O>
|
| 747 |
constexpr ranges::remove_copy_if_result<I, O>
|
| 748 |
ranges::remove_copy_if(I first, S last, O result, Pred pred, Proj proj = {});
|
| 749 |
template<input_range R, weakly_incrementable O, class Proj = identity,
|
| 750 |
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
|
| 751 |
requires indirectly_copyable<iterator_t<R>, O>
|
| 752 |
constexpr ranges::remove_copy_if_result<borrowed_iterator_t<R>, O>
|
| 753 |
ranges::remove_copy_if(R&& r, O result, Pred pred, Proj proj = {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 754 |
```
|
| 755 |
|
| 756 |
-
Let E be
|
| 757 |
|
| 758 |
- `bool(*i == value)` for `remove_copy`;
|
| 759 |
- `bool(pred(*i))` for `remove_copy_if`;
|
| 760 |
- `bool(invoke(proj, *i) == value)` for `ranges::remove_copy`;
|
| 761 |
- `bool(invoke(pred, invoke(proj, *i)))` for `ranges::remove_copy_if`.
|
| 762 |
|
| 763 |
-
Let
|
| 764 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 765 |
|
| 766 |
*Mandates:* `*first` is writable [[iterator.requirements.general]] to
|
| 767 |
`result`.
|
| 768 |
|
| 769 |
*Preconditions:* The ranges \[`first`, `last`) and \[`result`,
|
| 770 |
-
`result +
|
| 771 |
|
| 772 |
-
[*Note 2*: For the overloads
|
| 773 |
-
a performance cost if
|
| 774 |
-
does not meet the
|
| 775 |
-
([[cpp17.moveconstructible]]) requirements.
|
|
|
|
|
|
|
|
|
|
| 776 |
|
| 777 |
-
*Effects:* Copies
|
| 778 |
-
the range \[`first`, `last`) for which E is `false`
|
|
|
|
| 779 |
|
| 780 |
*Returns:*
|
| 781 |
|
| 782 |
- `result + `N, for the algorithms in namespace `std`.
|
| 783 |
-
- `{last, result + `N`}`, for the algorithms in namespace `ranges`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 784 |
|
| 785 |
-
*Complexity:*
|
| 786 |
predicate and any projection.
|
| 787 |
|
| 788 |
*Remarks:* Stable [[algorithm.stable]].
|
| 789 |
|
| 790 |
### Unique <a id="alg.unique">[[alg.unique]]</a>
|
|
@@ -810,10 +1123,20 @@ template<permutable I, sentinel_for<I> S, class Proj = identity,
|
|
| 810 |
template<forward_range R, class Proj = identity,
|
| 811 |
indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
|
| 812 |
requires permutable<iterator_t<R>>
|
| 813 |
constexpr borrowed_subrange_t<R>
|
| 814 |
ranges::unique(R&& r, C comp = {}, Proj proj = {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 815 |
```
|
| 816 |
|
| 817 |
Let `pred` be `equal_to{}` for the overloads with no parameter `pred`,
|
| 818 |
and let E be
|
| 819 |
|
|
@@ -875,52 +1198,83 @@ template<input_range R, weakly_incrementable O, class Proj = identity,
|
|
| 875 |
(forward_iterator<iterator_t<R>> ||
|
| 876 |
(input_iterator<O> && same_as<range_value_t<R>, iter_value_t<O>>) ||
|
| 877 |
indirectly_copyable_storable<iterator_t<R>, O>)
|
| 878 |
constexpr ranges::unique_copy_result<borrowed_iterator_t<R>, O>
|
| 879 |
ranges::unique_copy(R&& r, O result, C comp = {}, Proj proj = {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 880 |
```
|
| 881 |
|
| 882 |
Let `pred` be `equal_to{}` for the overloads in namespace `std` with no
|
| 883 |
-
parameter `pred`, and let E be
|
| 884 |
|
| 885 |
- `bool(pred(*i, *(i - 1)))` for the overloads in namespace `std`;
|
| 886 |
- `bool(invoke(comp, invoke(proj, *i), invoke(proj, *(i - 1))))` for the
|
| 887 |
overloads in namespace `ranges`.
|
| 888 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 889 |
*Mandates:* `*first` is writable [[iterator.requirements.general]] to
|
| 890 |
`result`.
|
| 891 |
|
| 892 |
*Preconditions:*
|
| 893 |
|
| 894 |
-
- The ranges \[`first`, `last`) and \[`result`, `result+
|
| 895 |
-
|
| 896 |
- For the overloads in namespace `std`:
|
| 897 |
- The comparison function is an equivalence relation.
|
| 898 |
- For the overloads with no `ExecutionPolicy`, let `T` be the value
|
| 899 |
type of `InputIterator`. If `InputIterator` models
|
| 900 |
`forward_iterator` [[iterator.concept.forward]], then there are no
|
| 901 |
additional requirements for `T`. Otherwise, if `OutputIterator`
|
| 902 |
meets the *Cpp17ForwardIterator* requirements and its value type is
|
| 903 |
the same as `T`, then `T` meets the *Cpp17CopyAssignable*
|
| 904 |
([[cpp17.copyassignable]]) requirements. Otherwise, `T` meets both
|
| 905 |
the *Cpp17CopyConstructible* ([[cpp17.copyconstructible]]) and
|
| 906 |
-
*Cpp17CopyAssignable* requirements.
|
| 907 |
-
with an `ExecutionPolicy`, there might be a performance cost if the
|
| 908 |
-
value type of `ForwardIterator1` does not meet both the
|
| 909 |
-
*Cpp17CopyConstructible* and *Cpp17CopyAssignable*
|
| 910 |
-
requirements. — *end note*]
|
| 911 |
|
| 912 |
-
*
|
| 913 |
-
|
| 914 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 915 |
|
| 916 |
*Returns:*
|
| 917 |
|
| 918 |
- `result + `N for the overloads in namespace `std`.
|
| 919 |
-
- `{last, result + `N`}` for the overloads in namespace `ranges`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 920 |
|
| 921 |
-
*Complexity:*
|
| 922 |
corresponding predicate and no more than twice as many applications of
|
| 923 |
any projection.
|
| 924 |
|
| 925 |
### Reverse <a id="alg.reverse">[[alg.reverse]]</a>
|
| 926 |
|
|
@@ -935,10 +1289,17 @@ template<bidirectional_iterator I, sentinel_for<I> S>
|
|
| 935 |
requires permutable<I>
|
| 936 |
constexpr I ranges::reverse(I first, S last);
|
| 937 |
template<bidirectional_range R>
|
| 938 |
requires permutable<iterator_t<R>>
|
| 939 |
constexpr borrowed_iterator_t<R> ranges::reverse(R&& r);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 940 |
```
|
| 941 |
|
| 942 |
*Preconditions:* For the overloads in namespace `std`,
|
| 943 |
`BidirectionalIterator` meets the *Cpp17ValueSwappable*
|
| 944 |
requirements [[swappable.requirements]].
|
|
@@ -988,10 +1349,38 @@ following assignment takes place:
|
|
| 988 |
- `result + `N for the overloads in namespace `std`.
|
| 989 |
- `{last, result + `N`}` for the overloads in namespace `ranges`.
|
| 990 |
|
| 991 |
*Complexity:* Exactly N assignments.
|
| 992 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 993 |
### Rotate <a id="alg.rotate">[[alg.rotate]]</a>
|
| 994 |
|
| 995 |
``` cpp
|
| 996 |
template<class ForwardIterator>
|
| 997 |
constexpr ForwardIterator
|
|
@@ -1001,10 +1390,13 @@ template<class ExecutionPolicy, class ForwardIterator>
|
|
| 1001 |
rotate(ExecutionPolicy&& exec,
|
| 1002 |
ForwardIterator first, ForwardIterator middle, ForwardIterator last);
|
| 1003 |
|
| 1004 |
template<permutable I, sentinel_for<I> S>
|
| 1005 |
constexpr subrange<I> ranges::rotate(I first, I middle, S last);
|
|
|
|
|
|
|
|
|
|
| 1006 |
```
|
| 1007 |
|
| 1008 |
*Preconditions:* \[`first`, `middle`) and \[`middle`, `last`) are valid
|
| 1009 |
ranges. For the overloads in namespace `std`, `ForwardIterator` meets
|
| 1010 |
the *Cpp17ValueSwappable* requirements [[swappable.requirements]], and
|
|
@@ -1033,10 +1425,22 @@ template<forward_range R>
|
|
| 1033 |
```
|
| 1034 |
|
| 1035 |
*Effects:* Equivalent to:
|
| 1036 |
`return ranges::rotate(ranges::begin(r), middle, ranges::end(r));`
|
| 1037 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1038 |
``` cpp
|
| 1039 |
template<class ForwardIterator, class OutputIterator>
|
| 1040 |
constexpr OutputIterator
|
| 1041 |
rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last,
|
| 1042 |
OutputIterator result);
|
|
@@ -1068,10 +1472,38 @@ following assignment takes place:
|
|
| 1068 |
- `result + `N for the overloads in namespace `std`.
|
| 1069 |
- `{last, result + `N`}` for the overload in namespace `ranges`.
|
| 1070 |
|
| 1071 |
*Complexity:* Exactly N assignments.
|
| 1072 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1073 |
``` cpp
|
| 1074 |
template<forward_range R, weakly_incrementable O>
|
| 1075 |
requires indirectly_copyable<iterator_t<R>, O>
|
| 1076 |
constexpr ranges::rotate_copy_result<borrowed_iterator_t<R>, O>
|
| 1077 |
ranges::rotate_copy(R&& r, iterator_t<R> middle, O result);
|
|
@@ -1081,10 +1513,24 @@ template<forward_range R, weakly_incrementable O>
|
|
| 1081 |
|
| 1082 |
``` cpp
|
| 1083 |
return ranges::rotate_copy(ranges::begin(r), middle, ranges::end(r), std::move(result));
|
| 1084 |
```
|
| 1085 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1086 |
### Sample <a id="alg.random.sample">[[alg.random.sample]]</a>
|
| 1087 |
|
| 1088 |
``` cpp
|
| 1089 |
template<class PopulationIterator, class SampleIterator,
|
| 1090 |
class Distance, class UniformRandomBitGenerator>
|
|
@@ -1193,26 +1639,34 @@ template<class ExecutionPolicy, class ForwardIterator>
|
|
| 1193 |
|
| 1194 |
template<permutable I, sentinel_for<I> S>
|
| 1195 |
constexpr subrange<I> ranges::shift_left(I first, S last, iter_difference_t<I> n);
|
| 1196 |
template<forward_range R>
|
| 1197 |
requires permutable<iterator_t<R>>
|
| 1198 |
-
constexpr borrowed_subrange_t<R> ranges::shift_left(R&& r, range_difference_t<R> n)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1199 |
```
|
| 1200 |
|
| 1201 |
*Preconditions:* `n >= 0` is `true`. For the overloads in namespace
|
| 1202 |
`std`, the type of `*first` meets the *Cpp17MoveAssignable*
|
| 1203 |
requirements.
|
| 1204 |
|
| 1205 |
*Effects:* If `n == 0` or `n >= last - first`, does nothing. Otherwise,
|
| 1206 |
moves the element from position `first + n + i` into position
|
| 1207 |
`first + i` for each non-negative integer `i < (last - first) - n`. For
|
| 1208 |
-
the
|
| 1209 |
-
|
| 1210 |
-
`i = (last - first) - n - 1`.
|
| 1211 |
|
| 1212 |
*Returns:* Let *NEW_LAST* be `first + (last - first - n)` if
|
| 1213 |
-
`n < last - first`, otherwise `first`.
|
| 1214 |
|
| 1215 |
- *NEW_LAST* for the overloads in namespace `std`.
|
| 1216 |
- `{first, `*`NEW_LAST`*`}` for the overloads in namespace `ranges`.
|
| 1217 |
|
| 1218 |
*Complexity:* At most `(last - first) - n` assignments.
|
|
@@ -1230,10 +1684,19 @@ template<class ExecutionPolicy, class ForwardIterator>
|
|
| 1230 |
template<permutable I, sentinel_for<I> S>
|
| 1231 |
constexpr subrange<I> ranges::shift_right(I first, S last, iter_difference_t<I> n);
|
| 1232 |
template<forward_range R>
|
| 1233 |
requires permutable<iterator_t<R>>
|
| 1234 |
constexpr borrowed_subrange_t<R> ranges::shift_right(R&& r, range_difference_t<R> n);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1235 |
```
|
| 1236 |
|
| 1237 |
*Preconditions:* `n >= 0` is `true`. For the overloads in namespace
|
| 1238 |
`std`, the type of `*first` meets the *Cpp17MoveAssignable*
|
| 1239 |
requirements, and `ForwardIterator` meets the
|
|
@@ -1242,20 +1705,19 @@ the *Cpp17ValueSwappable* requirements.
|
|
| 1242 |
|
| 1243 |
*Effects:* If `n == 0` or `n >= last - first`, does nothing. Otherwise,
|
| 1244 |
moves the element from position `first + i` into position
|
| 1245 |
`first + n + i` for each non-negative integer `i < (last - first) - n`.
|
| 1246 |
Does so in order starting from `i = (last - first) - n - 1` and
|
| 1247 |
-
proceeding to `i = 0` if
|
| 1248 |
|
| 1249 |
-
- for the overload in namespace `std`
|
| 1250 |
-
|
| 1251 |
-
|
| 1252 |
-
|
| 1253 |
-
`bidirectional_iterator`.
|
| 1254 |
|
| 1255 |
*Returns:* Let *NEW_FIRST* be `first + n` if `n < last - first`,
|
| 1256 |
-
otherwise `last`.
|
| 1257 |
|
| 1258 |
- *NEW_FIRST* for the overloads in namespace `std`.
|
| 1259 |
- `{`*`NEW_FIRST`*`, last}` for the overloads in namespace `ranges`.
|
| 1260 |
|
| 1261 |
*Complexity:* At most `(last - first) - n` assignments or swaps.
|
|
|
|
| 31 |
|
| 32 |
*Complexity:* Exactly N assignments.
|
| 33 |
|
| 34 |
``` cpp
|
| 35 |
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
|
| 36 |
+
ForwardIterator2 copy(ExecutionPolicy&& exec,
|
| 37 |
ForwardIterator1 first, ForwardIterator1 last,
|
| 38 |
ForwardIterator2 result);
|
| 39 |
+
|
| 40 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
|
| 41 |
+
random_access_iterator O, sized_sentinel_for<O> OutS>
|
| 42 |
+
requires indirectly_copyable<I, O>
|
| 43 |
+
ranges::copy_result<I, O>
|
| 44 |
+
ranges::copy(Ep&& exec, I first, S last, O result, OutS result_last);
|
| 45 |
+
template<execution-policy Ep, sized-random-access-range R, sized-random-access-range OutR>
|
| 46 |
+
requires indirectly_copyable<iterator_t<R>, iterator_t<OutR>>
|
| 47 |
+
ranges::copy_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
|
| 48 |
+
ranges::copy(Ep&& exec, R&& r, OutR&& result_r);
|
| 49 |
```
|
| 50 |
|
| 51 |
+
Let `result_last` be `result + (last - first)` for the overload in
|
| 52 |
+
namespace `std`.
|
| 53 |
+
|
| 54 |
+
Let N be min(`last - first`, `result_last - result`).
|
| 55 |
+
|
| 56 |
*Preconditions:* The ranges \[`first`, `last`) and \[`result`,
|
| 57 |
+
`result + `N) do not overlap.
|
| 58 |
|
| 59 |
+
*Effects:* Copies elements in the range \[`first`, `first + `N) into the
|
| 60 |
+
range \[`result`, `result + `N). For each non-negative integer n < N,
|
| 61 |
+
performs `*(result + `n`) = *(first + `n`)`.
|
| 62 |
|
| 63 |
+
*Returns:*
|
| 64 |
|
| 65 |
+
- `result + `N for the overload in namespace `std`.
|
| 66 |
+
- `{first + `N`, result + `N`}` for the overloads in namespace `ranges`.
|
| 67 |
+
|
| 68 |
+
*Complexity:* Exactly N assignments.
|
| 69 |
|
| 70 |
``` cpp
|
| 71 |
template<class InputIterator, class Size, class OutputIterator>
|
| 72 |
constexpr OutputIterator copy_n(InputIterator first, Size n,
|
| 73 |
OutputIterator result);
|
|
|
|
| 78 |
|
| 79 |
template<input_iterator I, weakly_incrementable O>
|
| 80 |
requires indirectly_copyable<I, O>
|
| 81 |
constexpr ranges::copy_n_result<I, O>
|
| 82 |
ranges::copy_n(I first, iter_difference_t<I> n, O result);
|
| 83 |
+
|
| 84 |
+
template<execution-policy Ep, random_access_iterator I, random_access_iterator O,
|
| 85 |
+
sized_sentinel_for<O> OutS>
|
| 86 |
+
requires indirectly_copyable<I, O>
|
| 87 |
+
ranges::copy_n_result<I, O>
|
| 88 |
+
ranges::copy_n(Ep&& exec, I first, iter_difference_t<I> n, O result, OutS result_last);
|
| 89 |
```
|
| 90 |
|
| 91 |
+
Let M be max(0, `n`).
|
| 92 |
+
|
| 93 |
+
Let `result_last` be `result + `M for the overloads with no parameter
|
| 94 |
+
`result_last`.
|
| 95 |
+
|
| 96 |
+
Let N be min(`result_last - result`, M).
|
| 97 |
|
| 98 |
*Mandates:* The type `Size` is convertible to an integral
|
| 99 |
type [[conv.integral]], [[class.conv]].
|
| 100 |
|
| 101 |
*Effects:* For each non-negative integer i < N, performs
|
|
|
|
| 126 |
template<input_range R, weakly_incrementable O, class Proj = identity,
|
| 127 |
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
|
| 128 |
requires indirectly_copyable<iterator_t<R>, O>
|
| 129 |
constexpr ranges::copy_if_result<borrowed_iterator_t<R>, O>
|
| 130 |
ranges::copy_if(R&& r, O result, Pred pred, Proj proj = {});
|
| 131 |
+
|
| 132 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
|
| 133 |
+
random_access_iterator O, sized_sentinel_for<O> OutS,
|
| 134 |
+
class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
|
| 135 |
+
requires indirectly_copyable<I, O>
|
| 136 |
+
ranges::copy_if_result<I, O>
|
| 137 |
+
ranges::copy_if(Ep&& exec, I first, S last, O result, OutS result_last,
|
| 138 |
+
Pred pred, Proj proj = {});
|
| 139 |
+
template<execution-policy Ep, sized-random-access-range R, sized-random-access-range OutR,
|
| 140 |
+
class Proj = identity,
|
| 141 |
+
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
|
| 142 |
+
requires indirectly_copyable<iterator_t<R>, iterator_t<OutR>>
|
| 143 |
+
ranges::copy_if_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
|
| 144 |
+
ranges::copy_if(Ep&& exec, R&& r, OutR&& result_r, Pred pred, Proj proj = {});
|
| 145 |
```
|
| 146 |
|
| 147 |
+
Let E(`i`) be:
|
| 148 |
|
| 149 |
- `bool(pred(*i))` for the overloads in namespace `std`;
|
| 150 |
- `bool(invoke(pred, invoke(proj, *i)))` for the overloads in namespace
|
| 151 |
+
`ranges`.
|
| 152 |
|
| 153 |
+
Let:
|
| 154 |
+
|
| 155 |
+
- M be the number of iterators `i` in the range \[`first`, `last`) for
|
| 156 |
+
which the condition E(`i`) holds;
|
| 157 |
+
- `result_last` be `result + `M for the overloads with no parameter
|
| 158 |
+
`result_last` or `result_r`;
|
| 159 |
+
- N be min(M, `result_last - result`).
|
| 160 |
|
| 161 |
*Preconditions:* The ranges \[`first`, `last`) and \[`result`,
|
| 162 |
+
`result + `N) do not overlap.
|
| 163 |
|
| 164 |
+
[*Note 1*: For the parallel algorithm overload in namespace `std`,
|
| 165 |
+
there can be a performance cost if
|
| 166 |
+
`iterator_traits<ForwardIterator1>::value_type` does not meet the
|
| 167 |
+
*Cpp17MoveConstructible* ([[cpp17.moveconstructible]]) requirements.
|
| 168 |
+
For the parallel algorithm overloads in namespace `ranges`, there can be
|
| 169 |
+
a performance cost if `iter_value_t<I>` does not model
|
| 170 |
+
`move_constructible`. — *end note*]
|
| 171 |
|
| 172 |
+
*Effects:* Copies the first N elements referred to by the iterator `i`
|
| 173 |
+
in the range \[`first`, `last`) for which E(`i`) is `true` into the
|
| 174 |
+
range \[`result`, `result + `N).
|
| 175 |
|
| 176 |
*Returns:*
|
| 177 |
|
| 178 |
- `result + `N for the overloads in namespace `std`.
|
| 179 |
+
- `{last, result + `N`}` for the overloads in namespace `ranges`, if N
|
| 180 |
+
is equal to M.
|
| 181 |
+
- Otherwise, `{j, result_last}` for the overloads in namespace `ranges`,
|
| 182 |
+
where `j` is the iterator in \[`first`, `last`) for which E(`j`) holds
|
| 183 |
+
and there are exactly N iterators `i` in \[`first`, `j`) for which
|
| 184 |
+
E(`i`) holds.
|
| 185 |
|
| 186 |
+
*Complexity:* At most `last - first` applications of the corresponding
|
| 187 |
predicate and any projection.
|
| 188 |
|
| 189 |
*Remarks:* Stable [[algorithm.stable]].
|
| 190 |
|
| 191 |
``` cpp
|
|
|
|
| 238 |
requires indirectly_movable<iterator_t<R>, O>
|
| 239 |
constexpr ranges::move_result<borrowed_iterator_t<R>, O>
|
| 240 |
ranges::move(R&& r, O result);
|
| 241 |
```
|
| 242 |
|
| 243 |
+
Let E(n) be
|
| 244 |
|
| 245 |
- `std::move(*(first + `n`))` for the overload in namespace `std`;
|
| 246 |
- `ranges::iter_move(first + `n`)` for the overloads in namespace
|
| 247 |
`ranges`.
|
| 248 |
|
|
|
|
| 251 |
*Preconditions:* `result` is not in the range \[`first`, `last`).
|
| 252 |
|
| 253 |
*Effects:* Moves elements in the range \[`first`, `last`) into the range
|
| 254 |
\[`result`, `result + `N) starting from `first` and proceeding to
|
| 255 |
`last`. For each non-negative integer n < N, performs
|
| 256 |
+
`*(result + `n`) = `E(n).
|
| 257 |
|
| 258 |
*Returns:*
|
| 259 |
|
| 260 |
- `result + `N for the overload in namespace `std`.
|
| 261 |
- `{last, result + `N`}` for the overloads in namespace `ranges`.
|
| 262 |
|
| 263 |
*Complexity:* Exactly N assignments.
|
| 264 |
|
| 265 |
``` cpp
|
| 266 |
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
|
| 267 |
+
ForwardIterator2 move(ExecutionPolicy&& exec,
|
| 268 |
ForwardIterator1 first, ForwardIterator1 last,
|
| 269 |
ForwardIterator2 result);
|
| 270 |
+
|
| 271 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
|
| 272 |
+
random_access_iterator O, sized_sentinel_for<O> OutS>
|
| 273 |
+
requires indirectly_movable<I, O>
|
| 274 |
+
ranges::move_result<I, O>
|
| 275 |
+
ranges::move(Ep&& exec, I first, S last, O result, OutS result_last);
|
| 276 |
+
template<execution-policy Ep, sized-random-access-range R, sized-random-access-range OutR>
|
| 277 |
+
requires indirectly_movable<iterator_t<R>, iterator_t<OutR>>
|
| 278 |
+
ranges::move_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
|
| 279 |
+
ranges::move(Ep&& exec, R&& r, OutR&& result_r);
|
| 280 |
```
|
| 281 |
|
| 282 |
+
Let E(n) be:
|
| 283 |
+
|
| 284 |
+
- `std::move(*(first + `n`))` for the overload in namespace `std`;
|
| 285 |
+
- `ranges::iter_move(first + `n`)` for the overloads in namespace
|
| 286 |
+
`ranges`.
|
| 287 |
+
|
| 288 |
+
Let `result_last` be `result + (last - first)` for the overloads in
|
| 289 |
+
namespace `std`.
|
| 290 |
+
|
| 291 |
+
Let N be min(`last - first`, `result_last - result`).
|
| 292 |
|
| 293 |
*Preconditions:* The ranges \[`first`, `last`) and \[`result`,
|
| 294 |
`result + `N) do not overlap.
|
| 295 |
|
| 296 |
+
*Effects:* Moves elements in the range \[`first`, `first + `N) into the
|
| 297 |
+
range \[`result`, `result + `N). For each non-negative integer n < N,
|
| 298 |
+
performs `*(result + `n`) = `E(n).
|
| 299 |
|
| 300 |
+
*Returns:*
|
| 301 |
+
|
| 302 |
+
- `result + `N for the overload in namespace `std`.
|
| 303 |
+
- `{first + `N`, result + `N`}` for the overloads in namespace `ranges`.
|
| 304 |
|
| 305 |
*Complexity:* Exactly N assignments.
|
| 306 |
|
| 307 |
``` cpp
|
| 308 |
template<class BidirectionalIterator1, class BidirectionalIterator2>
|
|
|
|
| 318 |
requires indirectly_movable<iterator_t<R>, I>
|
| 319 |
constexpr ranges::move_backward_result<borrowed_iterator_t<R>, I>
|
| 320 |
ranges::move_backward(R&& r, I result);
|
| 321 |
```
|
| 322 |
|
| 323 |
+
Let E(n) be
|
| 324 |
|
| 325 |
- `std::move(*(last - `n`))` for the overload in namespace `std`;
|
| 326 |
- `ranges::iter_move(last - `n`)` for the overloads in namespace
|
| 327 |
`ranges`.
|
| 328 |
|
|
|
|
| 332 |
|
| 333 |
*Effects:* Moves elements in the range \[`first`, `last`) into the range
|
| 334 |
\[`result - `N, `result`) starting from `last - 1` and proceeding to
|
| 335 |
`first`.[^3]
|
| 336 |
|
| 337 |
+
For each positive integer n ≤ N, performs `*(result - `n`) = `E(n).
|
| 338 |
|
| 339 |
*Returns:*
|
| 340 |
|
| 341 |
- `result - `N for the overload in namespace `std`.
|
| 342 |
- `{last, result - `N`}` for the overloads in namespace `ranges`.
|
|
|
|
| 362 |
ranges::swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
|
| 363 |
template<input_range R1, input_range R2>
|
| 364 |
requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
|
| 365 |
constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
|
| 366 |
ranges::swap_ranges(R1&& r1, R2&& r2);
|
| 367 |
+
|
| 368 |
+
template<execution-policy Ep, random_access_iterator I1, sized_sentinel_for<I1> S1,
|
| 369 |
+
random_access_iterator I2, sized_sentinel_for<I2> S2>
|
| 370 |
+
requires indirectly_swappable<I1, I2>
|
| 371 |
+
ranges::swap_ranges_result<I1, I2>
|
| 372 |
+
ranges::swap_ranges(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2);
|
| 373 |
+
template<execution-policy Ep, sized-random-access-range R1, sized-random-access-range R2>
|
| 374 |
+
requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
|
| 375 |
+
ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
|
| 376 |
+
ranges::swap_ranges(Ep&& exec, R1&& r1, R2&& r2);
|
| 377 |
```
|
| 378 |
|
| 379 |
Let:
|
| 380 |
|
| 381 |
+
- `last2` be `first2 + (last1 - first1)` for the overloads in namespace
|
| 382 |
+
`std` with no parameter named `last2`;
|
| 383 |
- M be min(`last1 - first1`, `last2 - first2`).
|
| 384 |
|
| 385 |
*Preconditions:* The two ranges \[`first1`, `last1`) and \[`first2`,
|
| 386 |
`last2`) do not overlap. For the overloads in namespace `std`,
|
| 387 |
`*(first1 + `n`)` is swappable with [[swappable.requirements]]
|
|
|
|
| 449 |
template<input_range R, weakly_incrementable O, copy_constructible F,
|
| 450 |
class Proj = identity>
|
| 451 |
requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R>, Proj>>>
|
| 452 |
constexpr ranges::unary_transform_result<borrowed_iterator_t<R>, O>
|
| 453 |
ranges::transform(R&& r, O result, F op, Proj proj = {});
|
| 454 |
+
|
| 455 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
|
| 456 |
+
random_access_iterator O, sized_sentinel_for<O> OutS,
|
| 457 |
+
copy_constructible F, class Proj = identity>
|
| 458 |
+
requires indirectly_writable<O, indirect_result_t<F&, projected<I, Proj>>>
|
| 459 |
+
ranges::unary_transform_result<I, O>
|
| 460 |
+
ranges::transform(Ep&& exec, I first1, S last1, O result, OutS result_last,
|
| 461 |
+
F op, Proj proj = {});
|
| 462 |
+
template<execution-policy Ep, sized-random-access-range R, sized-random-access-range OutR,
|
| 463 |
+
copy_constructible F, class Proj = identity>
|
| 464 |
+
requires indirectly_writable<iterator_t<OutR>,
|
| 465 |
+
indirect_result_t<F&, projected<iterator_t<R>, Proj>>>
|
| 466 |
+
ranges::unary_transform_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
|
| 467 |
+
ranges::transform(Ep&& exec, R&& r, OutR&& result_r, F op, Proj proj = {});
|
| 468 |
+
|
| 469 |
template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
|
| 470 |
weakly_incrementable O, copy_constructible F, class Proj1 = identity,
|
| 471 |
class Proj2 = identity>
|
| 472 |
requires indirectly_writable<O, indirect_result_t<F&, projected<I1, Proj1>,
|
| 473 |
projected<I2, Proj2>>>
|
|
|
|
| 479 |
requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R1>, Proj1>,
|
| 480 |
projected<iterator_t<R2>, Proj2>>>
|
| 481 |
constexpr ranges::binary_transform_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
|
| 482 |
ranges::transform(R1&& r1, R2&& r2, O result,
|
| 483 |
F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {});
|
| 484 |
+
|
| 485 |
+
template<execution-policy Ep, random_access_iterator I1, sized_sentinel_for<I1> S1,
|
| 486 |
+
random_access_iterator I2, sized_sentinel_for<I2> S2,
|
| 487 |
+
random_access_iterator O, sized_sentinel_for<O> OutS,
|
| 488 |
+
copy_constructible F, class Proj1 = identity, class Proj2 = identity>
|
| 489 |
+
requires indirectly_writable<O, indirect_result_t<F&, projected<I1, Proj1>,
|
| 490 |
+
projected<I2, Proj2>>>
|
| 491 |
+
ranges::binary_transform_result<I1, I2, O>
|
| 492 |
+
ranges::transform(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2,
|
| 493 |
+
O result, OutS result_last,
|
| 494 |
+
F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {});
|
| 495 |
+
template<execution-policy Ep, sized-random-access-range R1, sized-random-access-range R2,
|
| 496 |
+
sized-random-access-range OutR, copy_constructible F,
|
| 497 |
+
class Proj1 = identity, class Proj2 = identity>
|
| 498 |
+
requires indirectly_writable<iterator_t<OutR>,
|
| 499 |
+
indirect_result_t<F&, projected<iterator_t<R1>, Proj1>,
|
| 500 |
+
projected<iterator_t<R2>, Proj2>>>
|
| 501 |
+
ranges::binary_transform_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>,
|
| 502 |
+
borrowed_iterator_t<OutR>>
|
| 503 |
+
ranges::transform(Ep&& exec, R1&& r1, R2&& r2, OutR&& result_r,
|
| 504 |
+
F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {});
|
| 505 |
```
|
| 506 |
|
| 507 |
Let:
|
| 508 |
|
| 509 |
+
- `last2` be `first2 + (last1 - first1)` for the overloads in namespace
|
| 510 |
+
`std` with parameter `first2` but no parameter `last2`;
|
| 511 |
+
- M be `last1 - first1` for unary transforms, or
|
| 512 |
min(`last1 - first1`, `last2 - first2`) for binary transforms;
|
| 513 |
+
- `result_last` be `result + `M for the overloads with no parameter
|
| 514 |
+
`result_last` or `result_r`;
|
| 515 |
+
- N be min(M, `result_last - result`);
|
| 516 |
+
- E(`i`) be
|
| 517 |
- `op(*(first1 + (i - result)))` for unary transforms defined in
|
| 518 |
namespace `std`;
|
| 519 |
- `binary_op(*(first1 + (i - result)), *(first2 + (i - result)))` for
|
| 520 |
binary transforms defined in namespace `std`;
|
| 521 |
- `invoke(op, invoke(proj, *(first1 + (i - result))))` for unary
|
| 522 |
transforms defined in namespace `ranges`;
|
| 523 |
- `invoke(binary_op, invoke(proj1, *(first1 + (i - result))), invoke(proj2,*(first2 + (i - result))))`
|
| 524 |
for binary transforms defined in namespace `ranges`.
|
| 525 |
|
| 526 |
+
*Preconditions:* For parallel algorithm overloads `op` and `binary_op`
|
| 527 |
+
satisfy the requirements specified in [[algorithms.parallel.user]]. `op`
|
| 528 |
+
and `binary_op` do not invalidate iterators or subranges, nor modify
|
| 529 |
+
elements in the ranges
|
| 530 |
|
| 531 |
- \[`first1`, `first1 + `N\],
|
| 532 |
- \[`first2`, `first2 + `N\], and
|
| 533 |
- \[`result`, `result + `N\].[^4]
|
| 534 |
|
| 535 |
*Effects:* Assigns through every iterator `i` in the range \[`result`,
|
| 536 |
+
`result + `N) a new corresponding value equal to E(`i`).
|
| 537 |
|
| 538 |
*Returns:*
|
| 539 |
|
| 540 |
- `result + `N for the overloads defined in namespace `std`.
|
| 541 |
- `{first1 + `N`, result + `N`}` for unary transforms defined in
|
| 542 |
namespace `ranges`.
|
| 543 |
- `{first1 + `N`, first2 + `N`, result + `N`}` for binary transforms
|
| 544 |
defined in namespace `ranges`.
|
| 545 |
|
| 546 |
*Complexity:* Exactly N applications of `op` or `binary_op`, and any
|
| 547 |
+
projections. This requirement also applies to the parallel algorithm
|
| 548 |
+
overloads.
|
| 549 |
|
| 550 |
*Remarks:* `result` may be equal to `first1` or `first2`.
|
| 551 |
|
| 552 |
### Replace <a id="alg.replace">[[alg.replace]]</a>
|
| 553 |
|
| 554 |
``` cpp
|
| 555 |
+
template<class ForwardIterator, class T = iterator_traits<ForwardIterator>::value_type>
|
| 556 |
constexpr void replace(ForwardIterator first, ForwardIterator last,
|
| 557 |
const T& old_value, const T& new_value);
|
| 558 |
+
template<class ExecutionPolicy, class ForwardIterator,
|
| 559 |
+
class T = iterator_traits<ForwardIterator>::value_type>
|
| 560 |
void replace(ExecutionPolicy&& exec,
|
| 561 |
ForwardIterator first, ForwardIterator last,
|
| 562 |
const T& old_value, const T& new_value);
|
| 563 |
|
| 564 |
+
template<class ForwardIterator, class Predicate,
|
| 565 |
+
class T = iterator_traits<ForwardIterator>::value_type>
|
| 566 |
constexpr void replace_if(ForwardIterator first, ForwardIterator last,
|
| 567 |
Predicate pred, const T& new_value);
|
| 568 |
+
template<class ExecutionPolicy, class ForwardIterator, class Predicate,
|
| 569 |
+
class T = iterator_traits<ForwardIterator>::value_type>
|
| 570 |
void replace_if(ExecutionPolicy&& exec,
|
| 571 |
ForwardIterator first, ForwardIterator last,
|
| 572 |
Predicate pred, const T& new_value);
|
| 573 |
|
| 574 |
+
template<input_iterator I, sentinel_for<I> S, class Proj = identity,
|
| 575 |
+
class T1 = projected_value_t<I, Proj>, class T2 = T1>
|
| 576 |
requires indirectly_writable<I, const T2&> &&
|
| 577 |
indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
|
| 578 |
constexpr I
|
| 579 |
ranges::replace(I first, S last, const T1& old_value, const T2& new_value, Proj proj = {});
|
| 580 |
+
template<input_range R, class Proj = identity,
|
| 581 |
+
class T1 = projected_value_t<iterator_t<R>, Proj>, class T2 = T1>
|
| 582 |
requires indirectly_writable<iterator_t<R>, const T2&> &&
|
| 583 |
indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T1*>
|
| 584 |
constexpr borrowed_iterator_t<R>
|
| 585 |
ranges::replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {});
|
| 586 |
+
|
| 587 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
|
| 588 |
+
class Proj = identity, class T1 = projected_value_t<I, Proj>, class T2 = T1>
|
| 589 |
+
requires indirectly_writable<I, const T2&> &&
|
| 590 |
+
indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
|
| 591 |
+
I ranges::replace(Ep&& exec, I first, S last,
|
| 592 |
+
const T1& old_value, const T2& new_value, Proj proj = {});
|
| 593 |
+
template<execution-policy Ep, sized-random-access-range R, class Proj = identity,
|
| 594 |
+
class T1 = projected_value_t<iterator_t<R>, Proj>, class T2 = T1>
|
| 595 |
+
requires indirectly_writable<iterator_t<R>, const T2&> &&
|
| 596 |
+
indirect_binary_predicate<ranges::equal_to,
|
| 597 |
+
projected<iterator_t<R>, Proj>, const T1*>
|
| 598 |
+
borrowed_iterator_t<R>
|
| 599 |
+
ranges::replace(Ep&& exec, R&& r, const T1& old_value, const T2& new_value,
|
| 600 |
+
Proj proj = {});
|
| 601 |
+
|
| 602 |
+
template<input_iterator I, sentinel_for<I> S, class Proj = identity,
|
| 603 |
+
class T = projected_value_t<I, Proj>,
|
| 604 |
indirect_unary_predicate<projected<I, Proj>> Pred>
|
| 605 |
requires indirectly_writable<I, const T&>
|
| 606 |
constexpr I ranges::replace_if(I first, S last, Pred pred, const T& new_value, Proj proj = {});
|
| 607 |
+
template<input_range R, class Proj = identity, class T = projected_value_t<iterator_t<R>, Proj>,
|
| 608 |
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
|
| 609 |
requires indirectly_writable<iterator_t<R>, const T&>
|
| 610 |
constexpr borrowed_iterator_t<R>
|
| 611 |
ranges::replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {});
|
| 612 |
+
|
| 613 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
|
| 614 |
+
class Proj = identity, class T = projected_value_t<I, Proj>,
|
| 615 |
+
indirect_unary_predicate<projected<I, Proj>> Pred>
|
| 616 |
+
requires indirectly_writable<I, const T&>
|
| 617 |
+
I ranges::replace_if(Ep&& exec, I first, S last, Pred pred,
|
| 618 |
+
const T& new_value, Proj proj = {});
|
| 619 |
+
template<execution-policy Ep, sized-random-access-range R, class Proj = identity,
|
| 620 |
+
class T = projected_value_t<iterator_t<R>, Proj>,
|
| 621 |
+
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
|
| 622 |
+
requires indirectly_writable<iterator_t<R>, const T&>
|
| 623 |
+
borrowed_iterator_t<R>
|
| 624 |
+
ranges::replace_if(Ep&& exec, R&& r, Pred pred, const T& new_value, Proj proj = {});
|
| 625 |
```
|
| 626 |
|
| 627 |
+
Let E(`i`) be
|
| 628 |
|
| 629 |
- `bool(*i == old_value)` for `replace`;
|
| 630 |
- `bool(pred(*i))` for `replace_if`;
|
| 631 |
- `bool(invoke(proj, *i) == old_value)` for `ranges::replace`;
|
| 632 |
- `bool(invoke(pred, invoke(proj, *i)))` for `ranges::replace_if`.
|
| 633 |
|
| 634 |
*Mandates:* `new_value` is writable [[iterator.requirements.general]] to
|
| 635 |
`first`.
|
| 636 |
|
| 637 |
*Effects:* Substitutes elements referred by the iterator `i` in the
|
| 638 |
+
range \[`first`, `last`) with `new_value`, when E(`i`) is `true`.
|
| 639 |
|
| 640 |
*Returns:* `last` for the overloads in namespace `ranges`.
|
| 641 |
|
| 642 |
*Complexity:* Exactly `last - first` applications of the corresponding
|
| 643 |
predicate and any projection.
|
|
|
|
| 666 |
replace_copy_if(ExecutionPolicy&& exec,
|
| 667 |
ForwardIterator1 first, ForwardIterator1 last,
|
| 668 |
ForwardIterator2 result,
|
| 669 |
Predicate pred, const T& new_value);
|
| 670 |
|
| 671 |
+
template<input_iterator I, sentinel_for<I> S, class O,
|
| 672 |
+
class Proj = identity, class T1 = projected_value_t<I, Proj>, class T2 = iter_value_t<O>>
|
| 673 |
requires indirectly_copyable<I, O> &&
|
| 674 |
+
indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*> &&
|
| 675 |
+
output_iterator<O, const T2&>
|
| 676 |
constexpr ranges::replace_copy_result<I, O>
|
| 677 |
ranges::replace_copy(I first, S last, O result, const T1& old_value, const T2& new_value,
|
| 678 |
Proj proj = {});
|
| 679 |
+
template<input_range R, class O, class Proj = identity,
|
| 680 |
+
class T1 = projected_value_t<iterator_t<R>, Proj>, class T2 = iter_value_t<O>>
|
| 681 |
requires indirectly_copyable<iterator_t<R>, O> &&
|
| 682 |
indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T1*>
|
| 683 |
+
&& output_iterator<O, const T2&>
|
| 684 |
constexpr ranges::replace_copy_result<borrowed_iterator_t<R>, O>
|
| 685 |
ranges::replace_copy(R&& r, O result, const T1& old_value, const T2& new_value,
|
| 686 |
Proj proj = {});
|
| 687 |
|
| 688 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
|
| 689 |
+
random_access_iterator O, sized_sentinel_for<O> OutS,
|
| 690 |
+
class Proj = identity,
|
| 691 |
+
class T1 = projected_value_t<I, Proj>, class T2 = iter_value_t<O>>
|
| 692 |
+
requires indirectly_copyable<I, O> &&
|
| 693 |
+
indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*> &&
|
| 694 |
+
indirectly_writable<O, const T2&>
|
| 695 |
+
ranges::replace_copy_result<I, O>
|
| 696 |
+
ranges::replace_copy(Ep&& exec, I first, S last, O result, OutS result_last,
|
| 697 |
+
const T1& old_value, const T2& new_value, Proj proj = {});
|
| 698 |
+
template<execution-policy Ep, sized-random-access-range R, sized-random-access-range OutR,
|
| 699 |
+
class Proj = identity, class T1 = projected_value_t<iterator_t<R>, Proj>,
|
| 700 |
+
class T2 = range_value_t<OutR>>
|
| 701 |
+
requires indirectly_copyable<iterator_t<R>, iterator_t<OutR>> &&
|
| 702 |
+
indirect_binary_predicate<ranges::equal_to,
|
| 703 |
+
projected<iterator_t<R>, Proj>, const T1*> &&
|
| 704 |
+
indirectly_writable<iterator_t<OutR>, const T2&>
|
| 705 |
+
ranges::replace_copy_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
|
| 706 |
+
ranges::replace_copy(Ep&& exec, R&& r, OutR&& result_r, const T1& old_value,
|
| 707 |
+
const T2& new_value, Proj proj = {});
|
| 708 |
+
|
| 709 |
+
template<input_iterator I, sentinel_for<I> S,class O, class T = iter_value_t<O>,
|
| 710 |
class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
|
| 711 |
+
requires indirectly_copyable<I, O> && output_iterator<O, const T&>
|
| 712 |
constexpr ranges::replace_copy_if_result<I, O>
|
| 713 |
ranges::replace_copy_if(I first, S last, O result, Pred pred, const T& new_value,
|
| 714 |
Proj proj = {});
|
| 715 |
+
template<input_range R, class O, class T = iter_value_t<O>, class Proj = identity,
|
| 716 |
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
|
| 717 |
+
requires indirectly_copyable<iterator_t<R>, O> && output_iterator<O, const T&>
|
| 718 |
constexpr ranges::replace_copy_if_result<borrowed_iterator_t<R>, O>
|
| 719 |
ranges::replace_copy_if(R&& r, O result, Pred pred, const T& new_value,
|
| 720 |
Proj proj = {});
|
| 721 |
+
|
| 722 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
|
| 723 |
+
random_access_iterator O, sized_sentinel_for<O> OutS, class T = iter_value_t<O>,
|
| 724 |
+
class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
|
| 725 |
+
requires indirectly_copyable<I, O> && indirectly_writable<O, const T&>
|
| 726 |
+
ranges::replace_copy_if_result<I, O>
|
| 727 |
+
ranges::replace_copy_if(Ep&& exec, I first, S last, O result, OutS result_last,
|
| 728 |
+
Pred pred, const T& new_value, Proj proj = {});
|
| 729 |
+
template<execution-policy Ep, sized-random-access-range R, sized-random-access-range OutR,
|
| 730 |
+
class T = range_value_t<OutR>, class Proj = identity,
|
| 731 |
+
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
|
| 732 |
+
requires indirectly_copyable<iterator_t<R>, iterator_t<OutR>> &&
|
| 733 |
+
indirectly_writable<OutR, const T&>
|
| 734 |
+
ranges::replace_copy_if_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
|
| 735 |
+
ranges::replace_copy_if(Ep&& exec, R&& r, OutR&& result_r, Pred pred, const T& new_value,
|
| 736 |
+
Proj proj = {});
|
| 737 |
```
|
| 738 |
|
| 739 |
+
Let E(`i`) be
|
| 740 |
|
| 741 |
- `bool(*(first + (i - result)) == old_value)` for `replace_copy`;
|
| 742 |
- `bool(pred(*(first + (i - result))))` for `replace_copy_if`;
|
| 743 |
- `bool(invoke(proj, *(first + (i - result))) == old_value)` for
|
| 744 |
`ranges::replace_copy`;
|
| 745 |
- `bool(invoke(pred, invoke(proj, *(first + (i - result)))))` for
|
| 746 |
`ranges::replace_copy_if`.
|
| 747 |
|
| 748 |
+
Let:
|
| 749 |
+
|
| 750 |
+
- `result_last` be `result + (last - first)` for the overloads with no
|
| 751 |
+
parameter `result_last` or `result_r`;
|
| 752 |
+
- N be min(`last - first`, `result_last - result`).
|
| 753 |
+
|
| 754 |
*Mandates:* The results of the expressions `*first` and `new_value` are
|
| 755 |
writable [[iterator.requirements.general]] to `result`.
|
| 756 |
|
| 757 |
*Preconditions:* The ranges \[`first`, `last`) and \[`result`,
|
| 758 |
+
`result + `N) do not overlap.
|
| 759 |
|
| 760 |
*Effects:* Assigns through every iterator `i` in the range \[`result`,
|
| 761 |
+
`result + `N) a new corresponding value
|
| 762 |
|
| 763 |
+
- `new_value` if E(`i`) is `true` or
|
| 764 |
- `*(first + (i - result))` otherwise.
|
| 765 |
|
| 766 |
*Returns:*
|
| 767 |
|
| 768 |
+
- `result + `N for the overloads in namespace `std`.
|
| 769 |
+
- `{first + `N`, result + `N`}` for the overloads in namespace `ranges`.
|
|
|
|
| 770 |
|
| 771 |
+
*Complexity:* Exactly N applications of the corresponding predicate and
|
| 772 |
+
any projection.
|
| 773 |
|
| 774 |
### Fill <a id="alg.fill">[[alg.fill]]</a>
|
| 775 |
|
| 776 |
``` cpp
|
| 777 |
+
template<class ForwardIterator, class T = iterator_traits<ForwardIterator>::value_type>
|
| 778 |
constexpr void fill(ForwardIterator first, ForwardIterator last, const T& value);
|
| 779 |
+
template<class ExecutionPolicy, class ForwardIterator,
|
| 780 |
+
class T = iterator_traits<ForwardIterator>::value_type>
|
| 781 |
void fill(ExecutionPolicy&& exec,
|
| 782 |
ForwardIterator first, ForwardIterator last, const T& value);
|
| 783 |
|
| 784 |
+
template<class OutputIterator, class Size, class T = iterator_traits<OutputIterator>::value_type>
|
| 785 |
constexpr OutputIterator fill_n(OutputIterator first, Size n, const T& value);
|
| 786 |
+
template<class ExecutionPolicy, class ForwardIterator, class Size,
|
| 787 |
+
class T = iterator_traits<ForwardIterator>::value_type>
|
| 788 |
ForwardIterator fill_n(ExecutionPolicy&& exec,
|
| 789 |
ForwardIterator first, Size n, const T& value);
|
| 790 |
|
| 791 |
+
template<class O, sentinel_for<O> S, class T = iter_value_t<O>>
|
| 792 |
+
requires output_iterator<O, const T&>
|
| 793 |
constexpr O ranges::fill(O first, S last, const T& value);
|
| 794 |
+
template<class R, class T = range_value_t<R>>
|
| 795 |
+
requires output_range<R, const T&>
|
| 796 |
constexpr borrowed_iterator_t<R> ranges::fill(R&& r, const T& value);
|
| 797 |
+
template<class O, class T = iter_value_t<O>>
|
| 798 |
+
requires output_iterator<O, const T&>
|
| 799 |
constexpr O ranges::fill_n(O first, iter_difference_t<O> n, const T& value);
|
| 800 |
+
|
| 801 |
+
template<execution-policy Ep, random_access_iterator O, sized_sentinel_for<O> S,
|
| 802 |
+
class T = iter_value_t<O>>
|
| 803 |
+
requires indirectly_writable<O, const T&>
|
| 804 |
+
O ranges::fill(Ep&& exec, O first, S last, const T& value);
|
| 805 |
+
template<execution-policy Ep, sized-random-access-range R, class T = range_value_t<R>>
|
| 806 |
+
requires indirectly_writable<iterator_t<R>, const T&>
|
| 807 |
+
borrowed_iterator_t<R> fill(Ep&& exec, R&& r, const T& value);
|
| 808 |
+
template<execution-policy Ep, random_access_iterator O, class T = iter_value_t<O>>
|
| 809 |
+
requires indirectly_writable<O, const T&>
|
| 810 |
+
O ranges::fill_n(Ep&& exec, O first, iter_difference_t<O> n, const T& value);
|
| 811 |
```
|
| 812 |
|
| 813 |
Let N be max(0, `n`) for the `fill_n` algorithms, and `last - first` for
|
| 814 |
the `fill` algorithms.
|
| 815 |
|
|
|
|
| 849 |
requires invocable<F&> && output_range<R, invoke_result_t<F&>>
|
| 850 |
constexpr borrowed_iterator_t<R> ranges::generate(R&& r, F gen);
|
| 851 |
template<input_or_output_iterator O, copy_constructible F>
|
| 852 |
requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
|
| 853 |
constexpr O ranges::generate_n(O first, iter_difference_t<O> n, F gen);
|
| 854 |
+
|
| 855 |
+
template<execution-policy Ep, random_access_iterator O, sized_sentinel_for<O> S,
|
| 856 |
+
copy_constructible F>
|
| 857 |
+
requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
|
| 858 |
+
O ranges::generate(Ep&& exec, O first, S last, F gen);
|
| 859 |
+
template<execution-policy Ep, sized-random-access-range R, copy_constructible F>
|
| 860 |
+
requires invocable<F&> && indirectly_writable<iterator_t<R>, invoke_result_t<F&>>
|
| 861 |
+
borrowed_iterator_t<R> ranges::generate(Ep&& exec, R&& r, F gen);
|
| 862 |
+
template<execution-policy Ep, random_access_iterator O, copy_constructible F>
|
| 863 |
+
requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
|
| 864 |
+
O ranges::generate_n(Ep&& exec, O first, iter_difference_t<O> n, F gen);
|
| 865 |
```
|
| 866 |
|
| 867 |
Let N be max(0, `n`) for the `generate_n` algorithms, and `last - first`
|
| 868 |
for the `generate` algorithms.
|
| 869 |
|
|
|
|
| 875 |
|
| 876 |
*Returns:* `first + `N.
|
| 877 |
|
| 878 |
*Complexity:* Exactly N evaluations of `gen()` and assignments.
|
| 879 |
|
| 880 |
+
*Remarks:* `gen` may modify objects via its arguments for parallel
|
| 881 |
+
algorithm overloads [[algorithms.parallel.user]].
|
| 882 |
+
|
| 883 |
### Remove <a id="alg.remove">[[alg.remove]]</a>
|
| 884 |
|
| 885 |
``` cpp
|
| 886 |
+
template<class ForwardIterator, class T = iterator_traits<ForwardIterator>::value_type>
|
| 887 |
constexpr ForwardIterator remove(ForwardIterator first, ForwardIterator last,
|
| 888 |
const T& value);
|
| 889 |
+
template<class ExecutionPolicy, class ForwardIterator,
|
| 890 |
+
class T = iterator_traits<ForwardIterator>::value_type>
|
| 891 |
ForwardIterator remove(ExecutionPolicy&& exec,
|
| 892 |
ForwardIterator first, ForwardIterator last,
|
| 893 |
const T& value);
|
| 894 |
|
| 895 |
template<class ForwardIterator, class Predicate>
|
|
|
|
| 898 |
template<class ExecutionPolicy, class ForwardIterator, class Predicate>
|
| 899 |
ForwardIterator remove_if(ExecutionPolicy&& exec,
|
| 900 |
ForwardIterator first, ForwardIterator last,
|
| 901 |
Predicate pred);
|
| 902 |
|
| 903 |
+
template<permutable I, sentinel_for<I> S, class Proj = identity,
|
| 904 |
+
class T = projected_value_t<I, Proj>>
|
| 905 |
requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
|
| 906 |
constexpr subrange<I> ranges::remove(I first, S last, const T& value, Proj proj = {});
|
| 907 |
+
template<forward_range R, class Proj = identity,
|
| 908 |
+
class T = projected_value_t<iterator_t<R>, Proj>>
|
| 909 |
requires permutable<iterator_t<R>> &&
|
| 910 |
indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
|
| 911 |
constexpr borrowed_subrange_t<R>
|
| 912 |
ranges::remove(R&& r, const T& value, Proj proj = {});
|
| 913 |
+
|
| 914 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
|
| 915 |
+
class Proj = identity, class T = projected_value_t<I, Proj>>
|
| 916 |
+
requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
|
| 917 |
+
subrange<I>
|
| 918 |
+
ranges::remove(Ep&& exec, I first, S last, const T& value, Proj proj = {});
|
| 919 |
+
template<execution-policy Ep, sized-random-access-range R, class Proj = identity,
|
| 920 |
+
class T = projected_value_t<iterator_t<R>, Proj>>
|
| 921 |
+
requires permutable<iterator_t<R>> &&
|
| 922 |
+
indirect_binary_predicate<ranges::equal_to,
|
| 923 |
+
projected<iterator_t<R>, Proj>, const T*>
|
| 924 |
+
borrowed_subrange_t<R>
|
| 925 |
+
ranges::remove(Ep&& exec, R&& r, const T& value, Proj proj = {});
|
| 926 |
+
|
| 927 |
template<permutable I, sentinel_for<I> S, class Proj = identity,
|
| 928 |
indirect_unary_predicate<projected<I, Proj>> Pred>
|
| 929 |
constexpr subrange<I> ranges::remove_if(I first, S last, Pred pred, Proj proj = {});
|
| 930 |
template<forward_range R, class Proj = identity,
|
| 931 |
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
|
| 932 |
requires permutable<iterator_t<R>>
|
| 933 |
constexpr borrowed_subrange_t<R>
|
| 934 |
ranges::remove_if(R&& r, Pred pred, Proj proj = {});
|
| 935 |
+
|
| 936 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
|
| 937 |
+
class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
|
| 938 |
+
subrange<I>
|
| 939 |
+
ranges::remove_if(Ep&& exec, I first, S last, Pred pred, Proj proj = {});
|
| 940 |
+
template<execution-policy Ep, sized-random-access-range R, class Proj = identity,
|
| 941 |
+
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
|
| 942 |
+
requires permutable<iterator_t<R>>
|
| 943 |
+
borrowed_subrange_t<R>
|
| 944 |
+
ranges::remove_if(Ep&& exec, R&& r, Pred pred, Proj proj = {});
|
| 945 |
```
|
| 946 |
|
| 947 |
Let E be
|
| 948 |
|
| 949 |
- `bool(*i == value)` for `remove`;
|
|
|
|
| 972 |
the returned value, has a valid but unspecified state, because the
|
| 973 |
algorithms can eliminate elements by moving from elements that were
|
| 974 |
originally in that range. — *end note*]
|
| 975 |
|
| 976 |
``` cpp
|
| 977 |
+
template<class InputIterator, class OutputIterator,
|
| 978 |
+
class T = iterator_traits<InputIterator>::value_type>
|
| 979 |
constexpr OutputIterator
|
| 980 |
remove_copy(InputIterator first, InputIterator last,
|
| 981 |
OutputIterator result, const T& value);
|
| 982 |
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
|
| 983 |
+
class T = iterator_traits<ForwardIterator1>::value_type>
|
| 984 |
ForwardIterator2
|
| 985 |
remove_copy(ExecutionPolicy&& exec,
|
| 986 |
ForwardIterator1 first, ForwardIterator1 last,
|
| 987 |
ForwardIterator2 result, const T& value);
|
| 988 |
|
|
|
|
| 995 |
ForwardIterator2
|
| 996 |
remove_copy_if(ExecutionPolicy&& exec,
|
| 997 |
ForwardIterator1 first, ForwardIterator1 last,
|
| 998 |
ForwardIterator2 result, Predicate pred);
|
| 999 |
|
| 1000 |
+
template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
|
| 1001 |
+
class Proj = identity, class T = projected_value_t<I, Proj>>
|
| 1002 |
requires indirectly_copyable<I, O> &&
|
| 1003 |
indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
|
| 1004 |
constexpr ranges::remove_copy_result<I, O>
|
| 1005 |
ranges::remove_copy(I first, S last, O result, const T& value, Proj proj = {});
|
| 1006 |
+
template<input_range R, weakly_incrementable O, class Proj = identity,
|
| 1007 |
+
class T = projected_value_t<iterator_t<R>, Proj>>
|
| 1008 |
requires indirectly_copyable<iterator_t<R>, O> &&
|
| 1009 |
indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
|
| 1010 |
constexpr ranges::remove_copy_result<borrowed_iterator_t<R>, O>
|
| 1011 |
ranges::remove_copy(R&& r, O result, const T& value, Proj proj = {});
|
| 1012 |
+
|
| 1013 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
|
| 1014 |
+
random_access_iterator O, sized_sentinel_for<O> OutS,
|
| 1015 |
+
class Proj = identity, class T = projected_value_t<I, Proj>>
|
| 1016 |
+
requires indirectly_copyable<I, O> &&
|
| 1017 |
+
indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
|
| 1018 |
+
ranges::remove_copy_result<I, O>
|
| 1019 |
+
ranges::remove_copy(Ep&& exec, I first, S last, O result, OutS result_last,
|
| 1020 |
+
const T& value, Proj proj = {});
|
| 1021 |
+
template<execution-policy Ep, sized-random-access-range R, sized-random-access-range OutR,
|
| 1022 |
+
class Proj = identity, class T = projected_value_t<iterator_t<R>, Proj>>
|
| 1023 |
+
requires indirectly_copyable<iterator_t<R>, iterator_t<OutR>> &&
|
| 1024 |
+
indirect_binary_predicate<ranges::equal_to,
|
| 1025 |
+
projected<iterator_t<R>, Proj>, const T*>
|
| 1026 |
+
ranges::remove_copy_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
|
| 1027 |
+
ranges::remove_copy(Ep&& exec, R&& r, OutR&& result_r, const T& value, Proj proj = {});
|
| 1028 |
+
|
| 1029 |
template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
|
| 1030 |
class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
|
| 1031 |
requires indirectly_copyable<I, O>
|
| 1032 |
constexpr ranges::remove_copy_if_result<I, O>
|
| 1033 |
ranges::remove_copy_if(I first, S last, O result, Pred pred, Proj proj = {});
|
| 1034 |
template<input_range R, weakly_incrementable O, class Proj = identity,
|
| 1035 |
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
|
| 1036 |
requires indirectly_copyable<iterator_t<R>, O>
|
| 1037 |
constexpr ranges::remove_copy_if_result<borrowed_iterator_t<R>, O>
|
| 1038 |
ranges::remove_copy_if(R&& r, O result, Pred pred, Proj proj = {});
|
| 1039 |
+
|
| 1040 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
|
| 1041 |
+
random_access_iterator O, sized_sentinel_for<O> OutS,
|
| 1042 |
+
class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
|
| 1043 |
+
requires indirectly_copyable<I, O>
|
| 1044 |
+
ranges::remove_copy_if_result<I, O>
|
| 1045 |
+
ranges::remove_copy_if(Ep&& exec, I first, S last, O result, OutS result_last,
|
| 1046 |
+
Pred pred, Proj proj = {});
|
| 1047 |
+
template<execution-policy Ep, sized-random-access-range R, sized-random-access-range OutR,
|
| 1048 |
+
class Proj = identity,
|
| 1049 |
+
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
|
| 1050 |
+
requires indirectly_copyable<iterator_t<R>, iterator_t<OutR>>
|
| 1051 |
+
ranges::remove_copy_if_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
|
| 1052 |
+
ranges::remove_copy_if(Ep&& exec, R&& r, OutR&& result_r, Pred pred, Proj proj = {});
|
| 1053 |
```
|
| 1054 |
|
| 1055 |
+
Let E(`i`) be
|
| 1056 |
|
| 1057 |
- `bool(*i == value)` for `remove_copy`;
|
| 1058 |
- `bool(pred(*i))` for `remove_copy_if`;
|
| 1059 |
- `bool(invoke(proj, *i) == value)` for `ranges::remove_copy`;
|
| 1060 |
- `bool(invoke(pred, invoke(proj, *i)))` for `ranges::remove_copy_if`.
|
| 1061 |
|
| 1062 |
+
Let:
|
| 1063 |
+
|
| 1064 |
+
- M be the number of iterators `i` in \[`first`, `last`) for which
|
| 1065 |
+
E(`i`) is `false`;
|
| 1066 |
+
- `result_last` be `result + `M for the overloads with no parameter
|
| 1067 |
+
`result_last` or `result_r`;
|
| 1068 |
+
- N be min(M, `result_last - result`).
|
| 1069 |
|
| 1070 |
*Mandates:* `*first` is writable [[iterator.requirements.general]] to
|
| 1071 |
`result`.
|
| 1072 |
|
| 1073 |
*Preconditions:* The ranges \[`first`, `last`) and \[`result`,
|
| 1074 |
+
`result + `N) do not overlap.
|
| 1075 |
|
| 1076 |
+
[*Note 2*: For the parallel algorithm overloads in namespace `std`,
|
| 1077 |
+
there can be a performance cost if
|
| 1078 |
+
`iterator_traits<ForwardIterator1>::value_type` does not meet the
|
| 1079 |
+
*Cpp17MoveConstructible* ([[cpp17.moveconstructible]]) requirements.
|
| 1080 |
+
For the parallel algorithm overloads in namespace `ranges`, there can be
|
| 1081 |
+
a performance cost if `iter_value_t<I>` does not model
|
| 1082 |
+
`move_constructible`. — *end note*]
|
| 1083 |
|
| 1084 |
+
*Effects:* Copies the first N elements referred to by the iterator `i`
|
| 1085 |
+
in the range \[`first`, `last`) for which E(`i`) is `false` into the
|
| 1086 |
+
range \[`result`, `result + `N).
|
| 1087 |
|
| 1088 |
*Returns:*
|
| 1089 |
|
| 1090 |
- `result + `N, for the algorithms in namespace `std`.
|
| 1091 |
+
- `{last, result + `N`}`, for the algorithms in namespace `ranges`, if N
|
| 1092 |
+
is equal to M.
|
| 1093 |
+
- Otherwise, `{j, result_last}`, for the algorithms in namespace
|
| 1094 |
+
`ranges`, where `j` is the iterator in \[`first`, `last`) for which
|
| 1095 |
+
E(`j`) is `false` and there are exactly N iterators `i` in \[`first`,
|
| 1096 |
+
`j`) for which E(`i`) is `false`.
|
| 1097 |
|
| 1098 |
+
*Complexity:* At most `last - first` applications of the corresponding
|
| 1099 |
predicate and any projection.
|
| 1100 |
|
| 1101 |
*Remarks:* Stable [[algorithm.stable]].
|
| 1102 |
|
| 1103 |
### Unique <a id="alg.unique">[[alg.unique]]</a>
|
|
|
|
| 1123 |
template<forward_range R, class Proj = identity,
|
| 1124 |
indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
|
| 1125 |
requires permutable<iterator_t<R>>
|
| 1126 |
constexpr borrowed_subrange_t<R>
|
| 1127 |
ranges::unique(R&& r, C comp = {}, Proj proj = {});
|
| 1128 |
+
|
| 1129 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
|
| 1130 |
+
class Proj = identity,
|
| 1131 |
+
indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
|
| 1132 |
+
requires permutable<I>
|
| 1133 |
+
subrange<I> ranges::unique(Ep&& exec, I first, S last, C comp = {}, Proj proj = {});
|
| 1134 |
+
template<execution-policy Ep, sized-random-access-range R, class Proj = identity,
|
| 1135 |
+
indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
|
| 1136 |
+
requires permutable<iterator_t<R>>
|
| 1137 |
+
borrowed_subrange_t<R> ranges::unique(Ep&& exec, R&& r, C comp = {}, Proj proj = {});
|
| 1138 |
```
|
| 1139 |
|
| 1140 |
Let `pred` be `equal_to{}` for the overloads with no parameter `pred`,
|
| 1141 |
and let E be
|
| 1142 |
|
|
|
|
| 1198 |
(forward_iterator<iterator_t<R>> ||
|
| 1199 |
(input_iterator<O> && same_as<range_value_t<R>, iter_value_t<O>>) ||
|
| 1200 |
indirectly_copyable_storable<iterator_t<R>, O>)
|
| 1201 |
constexpr ranges::unique_copy_result<borrowed_iterator_t<R>, O>
|
| 1202 |
ranges::unique_copy(R&& r, O result, C comp = {}, Proj proj = {});
|
| 1203 |
+
|
| 1204 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
|
| 1205 |
+
random_access_iterator O, sized_sentinel_for<O> OutS, class Proj = identity,
|
| 1206 |
+
indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
|
| 1207 |
+
requires indirectly_copyable<I, O>
|
| 1208 |
+
ranges::unique_copy_result<I, O>
|
| 1209 |
+
ranges::unique_copy(Ep&& exec, I first, S last, O result, OutS result_last,
|
| 1210 |
+
C comp = {}, Proj proj = {});
|
| 1211 |
+
template<execution-policy Ep, sized-random-access-range R, sized-random-access-range OutR,
|
| 1212 |
+
class Proj = identity,
|
| 1213 |
+
indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
|
| 1214 |
+
requires indirectly_copyable<iterator_t<R>, iterator_t<OutR>>
|
| 1215 |
+
ranges::unique_copy_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
|
| 1216 |
+
ranges::unique_copy(Ep&& exec, R&& r, OutR&& result_r, C comp = {}, Proj proj = {});
|
| 1217 |
```
|
| 1218 |
|
| 1219 |
Let `pred` be `equal_to{}` for the overloads in namespace `std` with no
|
| 1220 |
+
parameter `pred`, and let E(`i`) be
|
| 1221 |
|
| 1222 |
- `bool(pred(*i, *(i - 1)))` for the overloads in namespace `std`;
|
| 1223 |
- `bool(invoke(comp, invoke(proj, *i), invoke(proj, *(i - 1))))` for the
|
| 1224 |
overloads in namespace `ranges`.
|
| 1225 |
|
| 1226 |
+
Let:
|
| 1227 |
+
|
| 1228 |
+
- M be the number of iterators `i` in the range \[`first + 1`, `last`)
|
| 1229 |
+
for which E(`i`) is `false`;
|
| 1230 |
+
- `result_last` be `result + `M` + 1` for the overloads with no
|
| 1231 |
+
parameter `result_last` or `result_r`;
|
| 1232 |
+
- N be min(M + 1, `result_last - result`).
|
| 1233 |
+
|
| 1234 |
*Mandates:* `*first` is writable [[iterator.requirements.general]] to
|
| 1235 |
`result`.
|
| 1236 |
|
| 1237 |
*Preconditions:*
|
| 1238 |
|
| 1239 |
+
- The ranges \[`first`, `last`) and \[`result`, `result + `N) do not
|
| 1240 |
+
overlap.
|
| 1241 |
- For the overloads in namespace `std`:
|
| 1242 |
- The comparison function is an equivalence relation.
|
| 1243 |
- For the overloads with no `ExecutionPolicy`, let `T` be the value
|
| 1244 |
type of `InputIterator`. If `InputIterator` models
|
| 1245 |
`forward_iterator` [[iterator.concept.forward]], then there are no
|
| 1246 |
additional requirements for `T`. Otherwise, if `OutputIterator`
|
| 1247 |
meets the *Cpp17ForwardIterator* requirements and its value type is
|
| 1248 |
the same as `T`, then `T` meets the *Cpp17CopyAssignable*
|
| 1249 |
([[cpp17.copyassignable]]) requirements. Otherwise, `T` meets both
|
| 1250 |
the *Cpp17CopyConstructible* ([[cpp17.copyconstructible]]) and
|
| 1251 |
+
*Cpp17CopyAssignable* requirements.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1252 |
|
| 1253 |
+
[*Note 1*: For the parallel algorithm overloads in namespace `std`,
|
| 1254 |
+
there can be a performance cost if the value type of `ForwardIterator1`
|
| 1255 |
+
does not meet both the *Cpp17CopyConstructible* and
|
| 1256 |
+
*Cpp17CopyAssignable* requirements. For the parallel algorithm overloads
|
| 1257 |
+
in namespace `ranges`, there can be a performance cost if
|
| 1258 |
+
`iter_value_t<I>` does not model `copyable`. — *end note*]
|
| 1259 |
+
|
| 1260 |
+
*Effects:* Copies only the first element from N consecutive groups of
|
| 1261 |
+
equivalent elements referred to by the iterator `i` in the range
|
| 1262 |
+
\[`first + 1`, `last`) for which E(`i`) holds into the range \[`result`,
|
| 1263 |
+
`result + `N).
|
| 1264 |
|
| 1265 |
*Returns:*
|
| 1266 |
|
| 1267 |
- `result + `N for the overloads in namespace `std`.
|
| 1268 |
+
- `{last, result + `N`}` for the overloads in namespace `ranges`, if N
|
| 1269 |
+
is equal to M + 1.
|
| 1270 |
+
- Otherwise, `{j, result_last}` for the overloads in namespace `ranges`,
|
| 1271 |
+
where `j` is the iterator in \[`first + 1`, `last`) for which E(`j`)
|
| 1272 |
+
is `false` and there are exactly N - 1 iterators `i` in \[`first + 1`,
|
| 1273 |
+
`j`) for which E(`i`) is `false`.
|
| 1274 |
|
| 1275 |
+
*Complexity:* At most `last - first - 1` applications of the
|
| 1276 |
corresponding predicate and no more than twice as many applications of
|
| 1277 |
any projection.
|
| 1278 |
|
| 1279 |
### Reverse <a id="alg.reverse">[[alg.reverse]]</a>
|
| 1280 |
|
|
|
|
| 1289 |
requires permutable<I>
|
| 1290 |
constexpr I ranges::reverse(I first, S last);
|
| 1291 |
template<bidirectional_range R>
|
| 1292 |
requires permutable<iterator_t<R>>
|
| 1293 |
constexpr borrowed_iterator_t<R> ranges::reverse(R&& r);
|
| 1294 |
+
|
| 1295 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S>
|
| 1296 |
+
requires permutable<I>
|
| 1297 |
+
I ranges::reverse(Ep&& exec, I first, S last);
|
| 1298 |
+
template<execution-policy Ep, sized-random-access-range R>
|
| 1299 |
+
requires permutable<iterator_t<R>>
|
| 1300 |
+
borrowed_iterator_t<R> ranges::reverse(Ep&& exec, R&& r);
|
| 1301 |
```
|
| 1302 |
|
| 1303 |
*Preconditions:* For the overloads in namespace `std`,
|
| 1304 |
`BidirectionalIterator` meets the *Cpp17ValueSwappable*
|
| 1305 |
requirements [[swappable.requirements]].
|
|
|
|
| 1349 |
- `result + `N for the overloads in namespace `std`.
|
| 1350 |
- `{last, result + `N`}` for the overloads in namespace `ranges`.
|
| 1351 |
|
| 1352 |
*Complexity:* Exactly N assignments.
|
| 1353 |
|
| 1354 |
+
``` cpp
|
| 1355 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
|
| 1356 |
+
random_access_iterator O, sized_sentinel_for<O> OutS>
|
| 1357 |
+
requires indirectly_copyable<I, O>
|
| 1358 |
+
ranges::reverse_copy_truncated_result<I, O>
|
| 1359 |
+
ranges::reverse_copy(Ep&& exec, I first, S last, O result,
|
| 1360 |
+
OutS result_last);
|
| 1361 |
+
template<execution-policy Ep, sized-random-access-range R, sized-random-access-range OutR>
|
| 1362 |
+
requires indirectly_copyable<iterator_t<R>, iterator_t<OutR>>
|
| 1363 |
+
ranges::reverse_copy_truncated_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
|
| 1364 |
+
ranges::reverse_copy(Ep&& exec, R&& r, OutR&& result_r);
|
| 1365 |
+
```
|
| 1366 |
+
|
| 1367 |
+
Let N be min(`last - first`, `result_last - result`), and let
|
| 1368 |
+
*NEW_FIRST* be `first + (last - first) - `N.
|
| 1369 |
+
|
| 1370 |
+
*Preconditions:* The ranges \[`first`, `last`) and \[`result`,
|
| 1371 |
+
`result + `N) do not overlap.
|
| 1372 |
+
|
| 1373 |
+
*Effects:* Copies the range \[*`NEW_FIRST`*, `last`) to the range
|
| 1374 |
+
\[`result`, `result + `N) such that for every non-negative integer i < N
|
| 1375 |
+
the following assignment takes place:
|
| 1376 |
+
`*(result + `N` - 1 - `i`) = *(`*`NEW_FIRST`*` + `i`)`.
|
| 1377 |
+
|
| 1378 |
+
*Returns:* `{last, `*`NEW_FIRST`*`, result + `N`}`.
|
| 1379 |
+
|
| 1380 |
+
*Complexity:* Exactly N assignments.
|
| 1381 |
+
|
| 1382 |
### Rotate <a id="alg.rotate">[[alg.rotate]]</a>
|
| 1383 |
|
| 1384 |
``` cpp
|
| 1385 |
template<class ForwardIterator>
|
| 1386 |
constexpr ForwardIterator
|
|
|
|
| 1390 |
rotate(ExecutionPolicy&& exec,
|
| 1391 |
ForwardIterator first, ForwardIterator middle, ForwardIterator last);
|
| 1392 |
|
| 1393 |
template<permutable I, sentinel_for<I> S>
|
| 1394 |
constexpr subrange<I> ranges::rotate(I first, I middle, S last);
|
| 1395 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S>
|
| 1396 |
+
requires permutable<I>
|
| 1397 |
+
subrange<I> ranges::rotate(Ep&& exec, I first, I middle, S last);
|
| 1398 |
```
|
| 1399 |
|
| 1400 |
*Preconditions:* \[`first`, `middle`) and \[`middle`, `last`) are valid
|
| 1401 |
ranges. For the overloads in namespace `std`, `ForwardIterator` meets
|
| 1402 |
the *Cpp17ValueSwappable* requirements [[swappable.requirements]], and
|
|
|
|
| 1425 |
```
|
| 1426 |
|
| 1427 |
*Effects:* Equivalent to:
|
| 1428 |
`return ranges::rotate(ranges::begin(r), middle, ranges::end(r));`
|
| 1429 |
|
| 1430 |
+
``` cpp
|
| 1431 |
+
template<execution-policy Ep, sized-random-access-range R>
|
| 1432 |
+
requires permutable<iterator_t<R>>
|
| 1433 |
+
borrowed_subrange_t<R> ranges::rotate(Ep&& exec, R&& r, iterator_t<R> middle);
|
| 1434 |
+
```
|
| 1435 |
+
|
| 1436 |
+
*Effects:* Equivalent to:
|
| 1437 |
+
|
| 1438 |
+
``` cpp
|
| 1439 |
+
return ranges::rotate(std::forward<Ep>(exec), ranges::begin(r), middle, ranges::end(r));
|
| 1440 |
+
```
|
| 1441 |
+
|
| 1442 |
``` cpp
|
| 1443 |
template<class ForwardIterator, class OutputIterator>
|
| 1444 |
constexpr OutputIterator
|
| 1445 |
rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last,
|
| 1446 |
OutputIterator result);
|
|
|
|
| 1472 |
- `result + `N for the overloads in namespace `std`.
|
| 1473 |
- `{last, result + `N`}` for the overload in namespace `ranges`.
|
| 1474 |
|
| 1475 |
*Complexity:* Exactly N assignments.
|
| 1476 |
|
| 1477 |
+
``` cpp
|
| 1478 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
|
| 1479 |
+
random_access_iterator O, sized_sentinel_for<O> OutS>
|
| 1480 |
+
requires indirectly_copyable<I, O>
|
| 1481 |
+
ranges::rotate_copy_truncated_result<I, O>
|
| 1482 |
+
ranges::rotate_copy(Ep&& exec, I first, I middle, S last, O result, OutS result_last);
|
| 1483 |
+
```
|
| 1484 |
+
|
| 1485 |
+
Let M be `last - first` and N be min(M, `result_last - result`).
|
| 1486 |
+
|
| 1487 |
+
*Preconditions:* \[`first`, `middle`) and \[`middle`, `last`) are valid
|
| 1488 |
+
ranges. The ranges \[`first`, `last`) and \[`result`, `result + `N) do
|
| 1489 |
+
not overlap.
|
| 1490 |
+
|
| 1491 |
+
*Effects:* Copies the range \[`first`, `last`) to the range \[`result`,
|
| 1492 |
+
`result + `N) such that for each non-negative integer i < N the
|
| 1493 |
+
following assignment takes place:
|
| 1494 |
+
`*(result + `i`) = *(first + (`i` + (middle - first)) % `M`)`.
|
| 1495 |
+
|
| 1496 |
+
*Returns:*
|
| 1497 |
+
|
| 1498 |
+
- `{middle + `N`, first, result + `N`}` if N is less than
|
| 1499 |
+
`last - middle`.
|
| 1500 |
+
- Otherwise,
|
| 1501 |
+
`{last, first + (`N` + (middle - first)) % `M`, result + `N`}`.
|
| 1502 |
+
|
| 1503 |
+
*Complexity:* Exactly N assignments.
|
| 1504 |
+
|
| 1505 |
``` cpp
|
| 1506 |
template<forward_range R, weakly_incrementable O>
|
| 1507 |
requires indirectly_copyable<iterator_t<R>, O>
|
| 1508 |
constexpr ranges::rotate_copy_result<borrowed_iterator_t<R>, O>
|
| 1509 |
ranges::rotate_copy(R&& r, iterator_t<R> middle, O result);
|
|
|
|
| 1513 |
|
| 1514 |
``` cpp
|
| 1515 |
return ranges::rotate_copy(ranges::begin(r), middle, ranges::end(r), std::move(result));
|
| 1516 |
```
|
| 1517 |
|
| 1518 |
+
``` cpp
|
| 1519 |
+
template<execution-policy Ep, sized-random-access-range R, sized-random-access-range OutR>
|
| 1520 |
+
requires indirectly_copyable<iterator_t<R>, iterator_t<OutR>>
|
| 1521 |
+
ranges::rotate_copy_truncated_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
|
| 1522 |
+
ranges::rotate_copy(Ep&& exec, R&& r, iterator_t<R> middle, OutR&& result_r);
|
| 1523 |
+
```
|
| 1524 |
+
|
| 1525 |
+
*Effects:* Equivalent to:
|
| 1526 |
+
|
| 1527 |
+
``` cpp
|
| 1528 |
+
return ranges::rotate_copy(std::forward<Ep>(exec), ranges::begin(r), middle, ranges::end(r),
|
| 1529 |
+
ranges::begin(result_r), ranges::end(result_r));
|
| 1530 |
+
```
|
| 1531 |
+
|
| 1532 |
### Sample <a id="alg.random.sample">[[alg.random.sample]]</a>
|
| 1533 |
|
| 1534 |
``` cpp
|
| 1535 |
template<class PopulationIterator, class SampleIterator,
|
| 1536 |
class Distance, class UniformRandomBitGenerator>
|
|
|
|
| 1639 |
|
| 1640 |
template<permutable I, sentinel_for<I> S>
|
| 1641 |
constexpr subrange<I> ranges::shift_left(I first, S last, iter_difference_t<I> n);
|
| 1642 |
template<forward_range R>
|
| 1643 |
requires permutable<iterator_t<R>>
|
| 1644 |
+
constexpr borrowed_subrange_t<R> ranges::shift_left(R&& r, range_difference_t<R> n);
|
| 1645 |
+
|
| 1646 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S>
|
| 1647 |
+
requires permutable<I>
|
| 1648 |
+
subrange<I>
|
| 1649 |
+
ranges::shift_left(Ep&& exec, I first, S last, iter_difference_t<I> n);
|
| 1650 |
+
template<execution-policy Ep, sized-random-access-range R>
|
| 1651 |
+
requires permutable<iterator_t<R>>
|
| 1652 |
+
borrowed_subrange_t<R>
|
| 1653 |
+
ranges::shift_left(Ep&& exec, R&& r, range_difference_t<R> n);
|
| 1654 |
```
|
| 1655 |
|
| 1656 |
*Preconditions:* `n >= 0` is `true`. For the overloads in namespace
|
| 1657 |
`std`, the type of `*first` meets the *Cpp17MoveAssignable*
|
| 1658 |
requirements.
|
| 1659 |
|
| 1660 |
*Effects:* If `n == 0` or `n >= last - first`, does nothing. Otherwise,
|
| 1661 |
moves the element from position `first + n + i` into position
|
| 1662 |
`first + i` for each non-negative integer `i < (last - first) - n`. For
|
| 1663 |
+
the non-parallel algorithm overloads, does so in order starting from
|
| 1664 |
+
`i = 0` and proceeding to `i = (last - first) - n - 1`.
|
|
|
|
| 1665 |
|
| 1666 |
*Returns:* Let *NEW_LAST* be `first + (last - first - n)` if
|
| 1667 |
+
`n < last - first`, otherwise `first`. Returns:
|
| 1668 |
|
| 1669 |
- *NEW_LAST* for the overloads in namespace `std`.
|
| 1670 |
- `{first, `*`NEW_LAST`*`}` for the overloads in namespace `ranges`.
|
| 1671 |
|
| 1672 |
*Complexity:* At most `(last - first) - n` assignments.
|
|
|
|
| 1684 |
template<permutable I, sentinel_for<I> S>
|
| 1685 |
constexpr subrange<I> ranges::shift_right(I first, S last, iter_difference_t<I> n);
|
| 1686 |
template<forward_range R>
|
| 1687 |
requires permutable<iterator_t<R>>
|
| 1688 |
constexpr borrowed_subrange_t<R> ranges::shift_right(R&& r, range_difference_t<R> n);
|
| 1689 |
+
|
| 1690 |
+
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S>
|
| 1691 |
+
requires permutable<I>
|
| 1692 |
+
subrange<I>
|
| 1693 |
+
ranges::shift_right(Ep&& exec, I first, S last, iter_difference_t<I> n);
|
| 1694 |
+
template<execution-policy Ep, sized-random-access-range R>
|
| 1695 |
+
requires permutable<iterator_t<R>>
|
| 1696 |
+
borrowed_subrange_t<R>
|
| 1697 |
+
ranges::shift_right(Ep&& exec, R&& r, range_difference_t<R> n);
|
| 1698 |
```
|
| 1699 |
|
| 1700 |
*Preconditions:* `n >= 0` is `true`. For the overloads in namespace
|
| 1701 |
`std`, the type of `*first` meets the *Cpp17MoveAssignable*
|
| 1702 |
requirements, and `ForwardIterator` meets the
|
|
|
|
| 1705 |
|
| 1706 |
*Effects:* If `n == 0` or `n >= last - first`, does nothing. Otherwise,
|
| 1707 |
moves the element from position `first + i` into position
|
| 1708 |
`first + n + i` for each non-negative integer `i < (last - first) - n`.
|
| 1709 |
Does so in order starting from `i = (last - first) - n - 1` and
|
| 1710 |
+
proceeding to `i = 0` if
|
| 1711 |
|
| 1712 |
+
- for the non-parallel algorithm overload in namespace `std`,
|
| 1713 |
+
`ForwardIterator` meets the *Cpp17BidirectionalIterator* requirements,
|
| 1714 |
+
- for the non-parallel algorithm overloads in namespace `ranges`, `I`
|
| 1715 |
+
models `bidirectional_iterator`.
|
|
|
|
| 1716 |
|
| 1717 |
*Returns:* Let *NEW_FIRST* be `first + n` if `n < last - first`,
|
| 1718 |
+
otherwise `last`. Returns:
|
| 1719 |
|
| 1720 |
- *NEW_FIRST* for the overloads in namespace `std`.
|
| 1721 |
- `{`*`NEW_FIRST`*`, last}` for the overloads in namespace `ranges`.
|
| 1722 |
|
| 1723 |
*Complexity:* At most `(last - first) - n` assignments or swaps.
|