tmp/tmpithzg185/{from.md → to.md}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
### Reduce <a id="reduce">[[reduce]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
template<class InputIterator>
|
| 5 |
-
typename iterator_traits<InputIterator>::value_type
|
| 6 |
reduce(InputIterator first, InputIterator last);
|
| 7 |
```
|
| 8 |
|
| 9 |
*Effects:* Equivalent to:
|
| 10 |
|
|
@@ -27,11 +27,11 @@ return reduce(std::forward<ExecutionPolicy>(exec), first, last,
|
|
| 27 |
typename iterator_traits<ForwardIterator>::value_type{});
|
| 28 |
```
|
| 29 |
|
| 30 |
``` cpp
|
| 31 |
template<class InputIterator, class T>
|
| 32 |
-
T reduce(InputIterator first, InputIterator last, T init);
|
| 33 |
```
|
| 34 |
|
| 35 |
*Effects:* Equivalent to:
|
| 36 |
|
| 37 |
``` cpp
|
|
@@ -50,26 +50,33 @@ template<class ExecutionPolicy, class ForwardIterator, class T>
|
|
| 50 |
return reduce(std::forward<ExecutionPolicy>(exec), first, last, init, plus<>());
|
| 51 |
```
|
| 52 |
|
| 53 |
``` cpp
|
| 54 |
template<class InputIterator, class T, class BinaryOperation>
|
| 55 |
-
T reduce(InputIterator first, InputIterator last, T init,
|
| 56 |
BinaryOperation binary_op);
|
| 57 |
template<class ExecutionPolicy, class ForwardIterator, class T, class BinaryOperation>
|
| 58 |
T reduce(ExecutionPolicy&& exec,
|
| 59 |
ForwardIterator first, ForwardIterator last, T init,
|
| 60 |
BinaryOperation binary_op);
|
| 61 |
```
|
| 62 |
|
| 63 |
-
*
|
| 64 |
-
|
| 65 |
-
- `
|
| 66 |
-
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
*Returns:* *GENERALIZED_SUM*(binary_op, init, \*i, ...) for every `i` in
|
| 73 |
\[`first`, `last`).
|
| 74 |
|
| 75 |
*Complexity:* 𝑂(`last - first`) applications of `binary_op`.
|
|
|
|
| 1 |
### Reduce <a id="reduce">[[reduce]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
template<class InputIterator>
|
| 5 |
+
constexpr typename iterator_traits<InputIterator>::value_type
|
| 6 |
reduce(InputIterator first, InputIterator last);
|
| 7 |
```
|
| 8 |
|
| 9 |
*Effects:* Equivalent to:
|
| 10 |
|
|
|
|
| 27 |
typename iterator_traits<ForwardIterator>::value_type{});
|
| 28 |
```
|
| 29 |
|
| 30 |
``` cpp
|
| 31 |
template<class InputIterator, class T>
|
| 32 |
+
constexpr T reduce(InputIterator first, InputIterator last, T init);
|
| 33 |
```
|
| 34 |
|
| 35 |
*Effects:* Equivalent to:
|
| 36 |
|
| 37 |
``` cpp
|
|
|
|
| 50 |
return reduce(std::forward<ExecutionPolicy>(exec), first, last, init, plus<>());
|
| 51 |
```
|
| 52 |
|
| 53 |
``` cpp
|
| 54 |
template<class InputIterator, class T, class BinaryOperation>
|
| 55 |
+
constexpr T reduce(InputIterator first, InputIterator last, T init,
|
| 56 |
BinaryOperation binary_op);
|
| 57 |
template<class ExecutionPolicy, class ForwardIterator, class T, class BinaryOperation>
|
| 58 |
T reduce(ExecutionPolicy&& exec,
|
| 59 |
ForwardIterator first, ForwardIterator last, T init,
|
| 60 |
BinaryOperation binary_op);
|
| 61 |
```
|
| 62 |
|
| 63 |
+
*Mandates:* All of
|
| 64 |
+
|
| 65 |
+
- `binary_op(init, *first)`,
|
| 66 |
+
- `binary_op(*first, init)`,
|
| 67 |
+
- `binary_op(init, init)`, and
|
| 68 |
+
- `binary_op(*first, *first)`
|
| 69 |
+
|
| 70 |
+
are convertible to `T`.
|
| 71 |
+
|
| 72 |
+
*Preconditions:*
|
| 73 |
+
|
| 74 |
+
- `T` meets the *Cpp17MoveConstructible* ([[cpp17.moveconstructible]])
|
| 75 |
+
requirements.
|
| 76 |
+
- `binary_op` neither invalidates iterators or subranges, nor modifies
|
| 77 |
+
elements in the range \[`first`, `last`\].
|
| 78 |
|
| 79 |
*Returns:* *GENERALIZED_SUM*(binary_op, init, \*i, ...) for every `i` in
|
| 80 |
\[`first`, `last`).
|
| 81 |
|
| 82 |
*Complexity:* 𝑂(`last - first`) applications of `binary_op`.
|