From Jason Turner

[inner.product]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmppc49l5pe/{from.md → to.md} +11 -11
tmp/tmppc49l5pe/{from.md → to.md} RENAMED
@@ -1,28 +1,28 @@
1
  ### Inner product <a id="inner.product">[[inner.product]]</a>
2
 
3
  ``` cpp
4
  template<class InputIterator1, class InputIterator2, class T>
5
- T inner_product(InputIterator1 first1, InputIterator1 last1,
6
  InputIterator2 first2, T init);
7
  template<class InputIterator1, class InputIterator2, class T,
8
  class BinaryOperation1, class BinaryOperation2>
9
- T inner_product(InputIterator1 first1, InputIterator1 last1,
10
  InputIterator2 first2, T init,
11
  BinaryOperation1 binary_op1,
12
  BinaryOperation2 binary_op2);
13
  ```
14
 
15
- *Requires:* `T` shall meet the requirements of `CopyConstructible`
16
- (Table  [[tab:copyconstructible]]) and `CopyAssignable`
17
- (Table  [[tab:copyassignable]]) types. In the ranges \[`first1`,
18
  `last1`\] and \[`first2`, `first2 + (last1 - first1)`\] `binary_op1` and
19
- `binary_op2` shall neither modify elements nor invalidate iterators or
20
- subranges.[^15]
21
 
22
  *Effects:* Computes its result by initializing the accumulator `acc`
23
  with the initial value `init` and then modifying it with
24
- `acc = acc + (*i1) * (*i2)` or
25
- `acc = binary_op1(acc, binary_op2(*i1, *i2))` for every iterator `i1` in
26
- the range \[`first1`, `last1`) and iterator `i2` in the range
27
- \[`first2`, `first2 + (last1 - first1)`) in order.
28
 
 
1
  ### Inner product <a id="inner.product">[[inner.product]]</a>
2
 
3
  ``` cpp
4
  template<class InputIterator1, class InputIterator2, class T>
5
+ constexpr T inner_product(InputIterator1 first1, InputIterator1 last1,
6
  InputIterator2 first2, T init);
7
  template<class InputIterator1, class InputIterator2, class T,
8
  class BinaryOperation1, class BinaryOperation2>
9
+ constexpr T inner_product(InputIterator1 first1, InputIterator1 last1,
10
  InputIterator2 first2, T init,
11
  BinaryOperation1 binary_op1,
12
  BinaryOperation2 binary_op2);
13
  ```
14
 
15
+ *Preconditions:* `T` meets the *Cpp17CopyConstructible*
16
+ ([[cpp17.copyconstructible]]) and *Cpp17CopyAssignable*
17
+ ([[cpp17.copyassignable]]) requirements. In the ranges \[`first1`,
18
  `last1`\] and \[`first2`, `first2 + (last1 - first1)`\] `binary_op1` and
19
+ `binary_op2` neither modifies elements nor invalidates iterators or
20
+ subranges. [^8]
21
 
22
  *Effects:* Computes its result by initializing the accumulator `acc`
23
  with the initial value `init` and then modifying it with
24
+ `acc = std::move(acc) + (*i1) * (*i2)` or
25
+ `acc = binary_op1(std::move(acc), binary_op2(*i1, *i2))` for every
26
+ iterator `i1` in the range \[`first1`, `last1`) and iterator `i2` in the
27
+ range \[`first2`, `first2 + (last1 - first1)`) in order.
28