tmp/tmpd49hfqgf/{from.md → to.md}
RENAMED
|
@@ -1,9 +1,11 @@
|
|
| 1 |
## Generalized numeric operations <a id="numeric.ops">[[numeric.ops]]</a>
|
| 2 |
|
|
|
|
|
|
|
| 3 |
[*Note 1*: The use of closed ranges as well as semi-open ranges to
|
| 4 |
-
specify requirements throughout
|
| 5 |
intentional. — *end note*]
|
| 6 |
|
| 7 |
### Definitions <a id="numerics.defns">[[numerics.defns]]</a>
|
| 8 |
|
| 9 |
Define `GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aN)` as follows:
|
|
@@ -386,11 +388,11 @@ GENERALIZED_NONCOMMUTATIVE_SUM(
|
|
| 386 |
*Remarks:* `result` may be equal to `first`.
|
| 387 |
|
| 388 |
[*Note 1*: The difference between `exclusive_scan` and `inclusive_scan`
|
| 389 |
is that `exclusive_scan` excludes the iᵗʰ input element from the iᵗʰ
|
| 390 |
sum. If `binary_op` is not mathematically associative, the behavior of
|
| 391 |
-
`exclusive_scan`
|
| 392 |
|
| 393 |
### Inclusive scan <a id="inclusive.scan">[[inclusive.scan]]</a>
|
| 394 |
|
| 395 |
``` cpp
|
| 396 |
template<class InputIterator, class OutputIterator>
|
|
@@ -481,11 +483,11 @@ through `result + K` the value of
|
|
| 481 |
*Remarks:* `result` may be equal to `first`.
|
| 482 |
|
| 483 |
[*Note 1*: The difference between `exclusive_scan` and `inclusive_scan`
|
| 484 |
is that `inclusive_scan` includes the iᵗʰ input element in the iᵗʰ sum.
|
| 485 |
If `binary_op` is not mathematically associative, the behavior of
|
| 486 |
-
`inclusive_scan`
|
| 487 |
|
| 488 |
### Transform exclusive scan <a id="transform.exclusive.scan">[[transform.exclusive.scan]]</a>
|
| 489 |
|
| 490 |
``` cpp
|
| 491 |
template<class InputIterator, class OutputIterator, class T,
|
|
@@ -538,11 +540,11 @@ GENERALIZED_NONCOMMUTATIVE_SUM(
|
|
| 538 |
|
| 539 |
[*Note 1*: The difference between `transform_exclusive_scan` and
|
| 540 |
`transform_inclusive_scan` is that `transform_exclusive_scan` excludes
|
| 541 |
the iᵗʰ input element from the iᵗʰ sum. If `binary_op` is not
|
| 542 |
mathematically associative, the behavior of `transform_exclusive_scan`
|
| 543 |
-
|
| 544 |
`unary_op` to `init`. — *end note*]
|
| 545 |
|
| 546 |
### Transform inclusive scan <a id="transform.inclusive.scan">[[transform.inclusive.scan]]</a>
|
| 547 |
|
| 548 |
``` cpp
|
|
@@ -621,11 +623,11 @@ through `result + K` the value of
|
|
| 621 |
|
| 622 |
[*Note 1*: The difference between `transform_exclusive_scan` and
|
| 623 |
`transform_inclusive_scan` is that `transform_inclusive_scan` includes
|
| 624 |
the iᵗʰ input element in the iᵗʰ sum. If `binary_op` is not
|
| 625 |
mathematically associative, the behavior of `transform_inclusive_scan`
|
| 626 |
-
|
| 627 |
`unary_op` to `init`. — *end note*]
|
| 628 |
|
| 629 |
### Adjacent difference <a id="adjacent.difference">[[adjacent.difference]]</a>
|
| 630 |
|
| 631 |
``` cpp
|
|
@@ -669,11 +671,11 @@ denotes an object of type `minus<>`.
|
|
| 669 |
|
| 670 |
- For the overloads with no `ExecutionPolicy`, `T` meets the
|
| 671 |
*Cpp17MoveAssignable* ([[cpp17.moveassignable]]) requirements.
|
| 672 |
- For all overloads, in the ranges \[`first`, `last`\] and \[`result`,
|
| 673 |
`result + (last - first)`\], `binary_op` neither modifies elements nor
|
| 674 |
-
|
| 675 |
|
| 676 |
*Effects:* For the overloads with no `ExecutionPolicy` and a non-empty
|
| 677 |
range, the function creates an accumulator `acc` of type `T`,
|
| 678 |
initializes it with `*first`, and assigns the result to `*result`. For
|
| 679 |
every iterator `i` in \[`first + 1`, `last`) in order, creates an object
|
|
@@ -710,18 +712,37 @@ expression `++val`, where `val` has type `T`, is well-formed.
|
|
| 710 |
\[`first`, `last`), assigns `*i = value` and increments `value` as if by
|
| 711 |
`++value`.
|
| 712 |
|
| 713 |
*Complexity:* Exactly `last - first` increments and assignments.
|
| 714 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 715 |
### Greatest common divisor <a id="numeric.ops.gcd">[[numeric.ops.gcd]]</a>
|
| 716 |
|
| 717 |
``` cpp
|
| 718 |
template<class M, class N>
|
| 719 |
constexpr common_type_t<M, N> gcd(M m, N n);
|
| 720 |
```
|
| 721 |
|
| 722 |
-
*Mandates:* `M` and `N` both are integer types
|
| 723 |
|
| 724 |
*Preconditions:* |`m`| and |`n`| are representable as a value of
|
| 725 |
`common_type_t<M, N>`.
|
| 726 |
|
| 727 |
[*Note 1*: These requirements ensure, for example, that
|
|
@@ -738,11 +759,11 @@ greatest common divisor of |`m`| and |`n`|.
|
|
| 738 |
``` cpp
|
| 739 |
template<class M, class N>
|
| 740 |
constexpr common_type_t<M, N> lcm(M m, N n);
|
| 741 |
```
|
| 742 |
|
| 743 |
-
*Mandates:* `M` and `N` both are integer types
|
| 744 |
|
| 745 |
*Preconditions:* |`m`| and |`n`| are representable as a value of
|
| 746 |
`common_type_t<M, N>`. The least common multiple of |`m`| and |`n`| is
|
| 747 |
representable as a value of type `common_type_t<M, N>`.
|
| 748 |
|
|
|
|
| 1 |
## Generalized numeric operations <a id="numeric.ops">[[numeric.ops]]</a>
|
| 2 |
|
| 3 |
+
### General <a id="numeric.ops.general">[[numeric.ops.general]]</a>
|
| 4 |
+
|
| 5 |
[*Note 1*: The use of closed ranges as well as semi-open ranges to
|
| 6 |
+
specify requirements throughout [[numeric.ops]] is
|
| 7 |
intentional. — *end note*]
|
| 8 |
|
| 9 |
### Definitions <a id="numerics.defns">[[numerics.defns]]</a>
|
| 10 |
|
| 11 |
Define `GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aN)` as follows:
|
|
|
|
| 388 |
*Remarks:* `result` may be equal to `first`.
|
| 389 |
|
| 390 |
[*Note 1*: The difference between `exclusive_scan` and `inclusive_scan`
|
| 391 |
is that `exclusive_scan` excludes the iᵗʰ input element from the iᵗʰ
|
| 392 |
sum. If `binary_op` is not mathematically associative, the behavior of
|
| 393 |
+
`exclusive_scan` can be nondeterministic. — *end note*]
|
| 394 |
|
| 395 |
### Inclusive scan <a id="inclusive.scan">[[inclusive.scan]]</a>
|
| 396 |
|
| 397 |
``` cpp
|
| 398 |
template<class InputIterator, class OutputIterator>
|
|
|
|
| 483 |
*Remarks:* `result` may be equal to `first`.
|
| 484 |
|
| 485 |
[*Note 1*: The difference between `exclusive_scan` and `inclusive_scan`
|
| 486 |
is that `inclusive_scan` includes the iᵗʰ input element in the iᵗʰ sum.
|
| 487 |
If `binary_op` is not mathematically associative, the behavior of
|
| 488 |
+
`inclusive_scan` can be nondeterministic. — *end note*]
|
| 489 |
|
| 490 |
### Transform exclusive scan <a id="transform.exclusive.scan">[[transform.exclusive.scan]]</a>
|
| 491 |
|
| 492 |
``` cpp
|
| 493 |
template<class InputIterator, class OutputIterator, class T,
|
|
|
|
| 540 |
|
| 541 |
[*Note 1*: The difference between `transform_exclusive_scan` and
|
| 542 |
`transform_inclusive_scan` is that `transform_exclusive_scan` excludes
|
| 543 |
the iᵗʰ input element from the iᵗʰ sum. If `binary_op` is not
|
| 544 |
mathematically associative, the behavior of `transform_exclusive_scan`
|
| 545 |
+
can be nondeterministic. `transform_exclusive_scan` does not apply
|
| 546 |
`unary_op` to `init`. — *end note*]
|
| 547 |
|
| 548 |
### Transform inclusive scan <a id="transform.inclusive.scan">[[transform.inclusive.scan]]</a>
|
| 549 |
|
| 550 |
``` cpp
|
|
|
|
| 623 |
|
| 624 |
[*Note 1*: The difference between `transform_exclusive_scan` and
|
| 625 |
`transform_inclusive_scan` is that `transform_inclusive_scan` includes
|
| 626 |
the iᵗʰ input element in the iᵗʰ sum. If `binary_op` is not
|
| 627 |
mathematically associative, the behavior of `transform_inclusive_scan`
|
| 628 |
+
can be nondeterministic. `transform_inclusive_scan` does not apply
|
| 629 |
`unary_op` to `init`. — *end note*]
|
| 630 |
|
| 631 |
### Adjacent difference <a id="adjacent.difference">[[adjacent.difference]]</a>
|
| 632 |
|
| 633 |
``` cpp
|
|
|
|
| 671 |
|
| 672 |
- For the overloads with no `ExecutionPolicy`, `T` meets the
|
| 673 |
*Cpp17MoveAssignable* ([[cpp17.moveassignable]]) requirements.
|
| 674 |
- For all overloads, in the ranges \[`first`, `last`\] and \[`result`,
|
| 675 |
`result + (last - first)`\], `binary_op` neither modifies elements nor
|
| 676 |
+
invalidates iterators or subranges.[^10]
|
| 677 |
|
| 678 |
*Effects:* For the overloads with no `ExecutionPolicy` and a non-empty
|
| 679 |
range, the function creates an accumulator `acc` of type `T`,
|
| 680 |
initializes it with `*first`, and assigns the result to `*result`. For
|
| 681 |
every iterator `i` in \[`first + 1`, `last`) in order, creates an object
|
|
|
|
| 712 |
\[`first`, `last`), assigns `*i = value` and increments `value` as if by
|
| 713 |
`++value`.
|
| 714 |
|
| 715 |
*Complexity:* Exactly `last - first` increments and assignments.
|
| 716 |
|
| 717 |
+
``` cpp
|
| 718 |
+
template<input_or_output_iterator O, sentinel_for<O> S, weakly_incrementable T>
|
| 719 |
+
requires indirectly_writable<O, const T&>
|
| 720 |
+
constexpr ranges::iota_result<O, T> ranges::iota(O first, S last, T value);
|
| 721 |
+
template<weakly_incrementable T, output_range<const T&> R>
|
| 722 |
+
constexpr ranges::iota_result<borrowed_iterator_t<R>, T> ranges::iota(R&& r, T value);
|
| 723 |
+
```
|
| 724 |
+
|
| 725 |
+
*Effects:* Equivalent to:
|
| 726 |
+
|
| 727 |
+
``` cpp
|
| 728 |
+
while (first != last) {
|
| 729 |
+
*first = as_const(value);
|
| 730 |
+
++first;
|
| 731 |
+
++value;
|
| 732 |
+
}
|
| 733 |
+
return {std::move(first), std::move(value)};
|
| 734 |
+
```
|
| 735 |
+
|
| 736 |
### Greatest common divisor <a id="numeric.ops.gcd">[[numeric.ops.gcd]]</a>
|
| 737 |
|
| 738 |
``` cpp
|
| 739 |
template<class M, class N>
|
| 740 |
constexpr common_type_t<M, N> gcd(M m, N n);
|
| 741 |
```
|
| 742 |
|
| 743 |
+
*Mandates:* `M` and `N` both are integer types other than cv `bool`.
|
| 744 |
|
| 745 |
*Preconditions:* |`m`| and |`n`| are representable as a value of
|
| 746 |
`common_type_t<M, N>`.
|
| 747 |
|
| 748 |
[*Note 1*: These requirements ensure, for example, that
|
|
|
|
| 759 |
``` cpp
|
| 760 |
template<class M, class N>
|
| 761 |
constexpr common_type_t<M, N> lcm(M m, N n);
|
| 762 |
```
|
| 763 |
|
| 764 |
+
*Mandates:* `M` and `N` both are integer types other than cv `bool`.
|
| 765 |
|
| 766 |
*Preconditions:* |`m`| and |`n`| are representable as a value of
|
| 767 |
`common_type_t<M, N>`. The least common multiple of |`m`| and |`n`| is
|
| 768 |
representable as a value of type `common_type_t<M, N>`.
|
| 769 |
|