From Jason Turner

[accumulate]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpp84ab94y/{from.md → to.md} +10 -10
tmp/tmpp84ab94y/{from.md → to.md} RENAMED
@@ -1,21 +1,21 @@
1
  ### Accumulate <a id="accumulate">[[accumulate]]</a>
2
 
3
  ``` cpp
4
  template<class InputIterator, class T>
5
- T accumulate(InputIterator first, InputIterator last, T init);
6
  template<class InputIterator, class T, class BinaryOperation>
7
- T accumulate(InputIterator first, InputIterator last, T init,
8
  BinaryOperation binary_op);
9
  ```
10
 
11
- *Requires:* `T` shall meet the requirements of `CopyConstructible`
12
- (Table  [[tab:copyconstructible]]) and `CopyAssignable`
13
- (Table  [[tab:copyassignable]]) types. In the range \[`first`, `last`\],
14
- `binary_op` shall neither modify elements nor invalidate iterators or
15
- subranges.[^13]
16
 
17
  *Effects:* Computes its result by initializing the accumulator `acc`
18
- with the initial value `init` and then modifies it with `acc = acc + *i`
19
- or `acc = binary_op(acc, *i)` for every iterator `i` in the range
20
- \[`first`, `last`) in order.[^14]
21
 
 
1
  ### Accumulate <a id="accumulate">[[accumulate]]</a>
2
 
3
  ``` cpp
4
  template<class InputIterator, class T>
5
+ constexpr T accumulate(InputIterator first, InputIterator last, T init);
6
  template<class InputIterator, class T, class BinaryOperation>
7
+ constexpr T accumulate(InputIterator first, InputIterator last, T init,
8
  BinaryOperation binary_op);
9
  ```
10
 
11
+ *Preconditions:* `T` meets the *Cpp17CopyConstructible*
12
+ ([[cpp17.copyconstructible]]) and *Cpp17CopyAssignable*
13
+ ([[cpp17.copyassignable]]) requirements. In the range \[`first`,
14
+ `last`\], `binary_op` neither modifies elements nor invalidates
15
+ iterators or subranges. [^6]
16
 
17
  *Effects:* Computes its result by initializing the accumulator `acc`
18
+ with the initial value `init` and then modifies it with
19
+ `acc = std::move(acc) + *i` or `acc = binary_op(std::move(acc), *i)` for
20
+ every iterator `i` in the range \[`first`, `last`) in order. [^7]
21