tmp/tmpmd1lne2f/{from.md → to.md}
RENAMED
|
@@ -1,33 +1,34 @@
|
|
| 1 |
### Partial sum <a id="partial.sum">[[partial.sum]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
template<class InputIterator, class OutputIterator>
|
| 5 |
-
|
| 6 |
-
InputIterator first, InputIterator last,
|
| 7 |
OutputIterator result);
|
| 8 |
template<class InputIterator, class OutputIterator, class BinaryOperation>
|
| 9 |
-
|
| 10 |
-
InputIterator first, InputIterator last,
|
| 11 |
OutputIterator result, BinaryOperation binary_op);
|
| 12 |
```
|
| 13 |
|
| 14 |
-
*
|
| 15 |
-
|
| 16 |
-
`binary_op(acc, *i)`
|
| 17 |
-
`InputIterator`’s value type. `acc`
|
| 18 |
-
writable
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
| 22 |
|
| 23 |
*Effects:* For a non-empty range, the function creates an accumulator
|
| 24 |
`acc` whose type is `InputIterator`’s value type, initializes it with
|
| 25 |
`*first`, and assigns the result to `*result`. For every iterator `i` in
|
| 26 |
\[`first + 1`, `last`) in order, `acc` is then modified by
|
| 27 |
-
`acc = acc + *i` or `acc = binary_op(acc, *i)` and
|
| 28 |
-
assigned to `*(result + (i - first))`.
|
| 29 |
|
| 30 |
*Returns:* `result + (last - first)`.
|
| 31 |
|
| 32 |
*Complexity:* Exactly `(last - first) - 1` applications of the binary
|
| 33 |
operation.
|
|
|
|
| 1 |
### Partial sum <a id="partial.sum">[[partial.sum]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
template<class InputIterator, class OutputIterator>
|
| 5 |
+
constexpr OutputIterator
|
| 6 |
+
partial_sum(InputIterator first, InputIterator last,
|
| 7 |
OutputIterator result);
|
| 8 |
template<class InputIterator, class OutputIterator, class BinaryOperation>
|
| 9 |
+
constexpr OutputIterator
|
| 10 |
+
partial_sum(InputIterator first, InputIterator last,
|
| 11 |
OutputIterator result, BinaryOperation binary_op);
|
| 12 |
```
|
| 13 |
|
| 14 |
+
*Mandates:* `InputIterator`’s value type is constructible from `*first`.
|
| 15 |
+
The result of the expression `std::move(acc) + *i` or
|
| 16 |
+
`binary_op(std::move(acc), *i)` is implicitly convertible to
|
| 17 |
+
`InputIterator`’s value type. `acc` is
|
| 18 |
+
writable [[iterator.requirements.general]] to `result`.
|
| 19 |
+
|
| 20 |
+
*Preconditions:* In the ranges \[`first`, `last`\] and \[`result`,
|
| 21 |
+
`result + (last - first)`\] `binary_op` neither modifies elements nor
|
| 22 |
+
invalidates iterators or subranges. [^9]
|
| 23 |
|
| 24 |
*Effects:* For a non-empty range, the function creates an accumulator
|
| 25 |
`acc` whose type is `InputIterator`’s value type, initializes it with
|
| 26 |
`*first`, and assigns the result to `*result`. For every iterator `i` in
|
| 27 |
\[`first + 1`, `last`) in order, `acc` is then modified by
|
| 28 |
+
`acc = std::move(acc) + *i` or `acc = binary_op(std::move(acc), *i)` and
|
| 29 |
+
the result is assigned to `*(result + (i - first))`.
|
| 30 |
|
| 31 |
*Returns:* `result + (last - first)`.
|
| 32 |
|
| 33 |
*Complexity:* Exactly `(last - first) - 1` applications of the binary
|
| 34 |
operation.
|