From Jason Turner

[transform.reduce]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpn_5irdn_/{from.md → to.md} +37 -21
tmp/tmpn_5irdn_/{from.md → to.md} RENAMED
@@ -1,30 +1,40 @@
1
  ### Transform reduce <a id="transform.reduce">[[transform.reduce]]</a>
2
 
3
  ``` cpp
4
  template<class InputIterator1, class InputIterator2, class T>
5
- T transform_reduce(InputIterator1 first1, InputIterator1 last1,
6
  InputIterator2 first2,
7
  T init);
8
- template <class ExecutionPolicy,
9
- class ForwardIterator1, class ForwardIterator2, class T>
10
- T transform_reduce(ExecutionPolicy&& exec,
11
- ForwardIterator1 first1, ForwardIterator1 last1,
12
- ForwardIterator2 first2,
13
- T init);
14
  ```
15
 
16
  *Effects:* Equivalent to:
17
 
18
  ``` cpp
19
  return transform_reduce(first1, last1, first2, init, plus<>(), multiplies<>());
20
  ```
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  ``` cpp
23
  template<class InputIterator1, class InputIterator2, class T,
24
  class BinaryOperation1, class BinaryOperation2>
25
- T transform_reduce(InputIterator1 first1, InputIterator1 last1,
26
  InputIterator2 first2,
27
  T init,
28
  BinaryOperation1 binary_op1,
29
  BinaryOperation2 binary_op2);
30
  template<class ExecutionPolicy,
@@ -36,22 +46,25 @@ template <class ExecutionPolicy,
36
  T init,
37
  BinaryOperation1 binary_op1,
38
  BinaryOperation2 binary_op2);
39
  ```
40
 
41
- *Requires:*
42
 
43
- - `T` shall be `MoveConstructible` (Table  [[tab:moveconstructible]]).
44
- - All of
45
  - `binary_op1(init, init)`,
46
  - `binary_op1(init, binary_op2(*first1, *first2))`,
47
  - `binary_op1(binary_op2(*first1, *first2), init)`, and
48
  - `binary_op1(binary_op2(*first1, *first2), binary_op2(*first1, *first2))`
49
 
50
- shall be convertible to `T`.
51
- - Neither `binary_op1` nor `binary_op2` shall invalidate subranges, or
52
- modify elements in the ranges \[`first1`, `last1`\] and \[`first2`,
 
 
 
 
 
53
  `first2 + (last1 - first1)`\].
54
 
55
  *Returns:*
56
 
57
  ``` cpp
@@ -64,32 +77,35 @@ for every iterator `i` in \[`first1`, `last1`).
64
  `binary_op2`.
65
 
66
  ``` cpp
67
  template<class InputIterator, class T,
68
  class BinaryOperation, class UnaryOperation>
69
- T transform_reduce(InputIterator first, InputIterator last, T init,
70
  BinaryOperation binary_op, UnaryOperation unary_op);
71
  template<class ExecutionPolicy,
72
  class ForwardIterator, class T,
73
  class BinaryOperation, class UnaryOperation>
74
  T transform_reduce(ExecutionPolicy&& exec,
75
  ForwardIterator first, ForwardIterator last,
76
  T init, BinaryOperation binary_op, UnaryOperation unary_op);
77
  ```
78
 
79
- *Requires:*
80
 
81
- - `T` shall be `MoveConstructible` (Table  [[tab:moveconstructible]]).
82
- - All of
83
  - `binary_op(init, init)`,
84
  - `binary_op(init, unary_op(*first))`,
85
  - `binary_op(unary_op(*first), init)`, and
86
  - `binary_op(unary_op(*first), unary_op(*first))`
87
 
88
- shall be convertible to `T`.
89
- - Neither `unary_op` nor `binary_op` shall invalidate subranges, or
90
- modify elements in the range \[`first`, `last`\].
 
 
 
 
 
91
 
92
  *Returns:*
93
 
94
  ``` cpp
95
  GENERALIZED_SUM(binary_op, init, unary_op(*i), ...)
 
1
  ### Transform reduce <a id="transform.reduce">[[transform.reduce]]</a>
2
 
3
  ``` cpp
4
  template<class InputIterator1, class InputIterator2, class T>
5
+ constexpr T transform_reduce(InputIterator1 first1, InputIterator1 last1,
6
  InputIterator2 first2,
7
  T init);
 
 
 
 
 
 
8
  ```
9
 
10
  *Effects:* Equivalent to:
11
 
12
  ``` cpp
13
  return transform_reduce(first1, last1, first2, init, plus<>(), multiplies<>());
14
  ```
15
 
16
+ ``` cpp
17
+ template<class ExecutionPolicy,
18
+ class ForwardIterator1, class ForwardIterator2, class T>
19
+ T transform_reduce(ExecutionPolicy&& exec,
20
+ ForwardIterator1 first1, ForwardIterator1 last1,
21
+ ForwardIterator2 first2,
22
+ T init);
23
+ ```
24
+
25
+ *Effects:* Equivalent to:
26
+
27
+ ``` cpp
28
+ return transform_reduce(std::forward<ExecutionPolicy>(exec),
29
+ first1, last1, first2, init, plus<>(), multiplies<>());
30
+ ```
31
+
32
  ``` cpp
33
  template<class InputIterator1, class InputIterator2, class T,
34
  class BinaryOperation1, class BinaryOperation2>
35
+ constexpr T transform_reduce(InputIterator1 first1, InputIterator1 last1,
36
  InputIterator2 first2,
37
  T init,
38
  BinaryOperation1 binary_op1,
39
  BinaryOperation2 binary_op2);
40
  template<class ExecutionPolicy,
 
46
  T init,
47
  BinaryOperation1 binary_op1,
48
  BinaryOperation2 binary_op2);
49
  ```
50
 
51
+ *Mandates:* All of
52
 
 
 
53
  - `binary_op1(init, init)`,
54
  - `binary_op1(init, binary_op2(*first1, *first2))`,
55
  - `binary_op1(binary_op2(*first1, *first2), init)`, and
56
  - `binary_op1(binary_op2(*first1, *first2), binary_op2(*first1, *first2))`
57
 
58
+ are convertible to `T`.
59
+
60
+ *Preconditions:*
61
+
62
+ - `T` meets the *Cpp17MoveConstructible* ([[cpp17.moveconstructible]])
63
+ requirements.
64
+ - Neither `binary_op1` nor `binary_op2` invalidates subranges, nor
65
+ modifies elements in the ranges \[`first1`, `last1`\] and \[`first2`,
66
  `first2 + (last1 - first1)`\].
67
 
68
  *Returns:*
69
 
70
  ``` cpp
 
77
  `binary_op2`.
78
 
79
  ``` cpp
80
  template<class InputIterator, class T,
81
  class BinaryOperation, class UnaryOperation>
82
+ constexpr T transform_reduce(InputIterator first, InputIterator last, T init,
83
  BinaryOperation binary_op, UnaryOperation unary_op);
84
  template<class ExecutionPolicy,
85
  class ForwardIterator, class T,
86
  class BinaryOperation, class UnaryOperation>
87
  T transform_reduce(ExecutionPolicy&& exec,
88
  ForwardIterator first, ForwardIterator last,
89
  T init, BinaryOperation binary_op, UnaryOperation unary_op);
90
  ```
91
 
92
+ *Mandates:* All of
93
 
 
 
94
  - `binary_op(init, init)`,
95
  - `binary_op(init, unary_op(*first))`,
96
  - `binary_op(unary_op(*first), init)`, and
97
  - `binary_op(unary_op(*first), unary_op(*first))`
98
 
99
+ are convertible to `T`.
100
+
101
+ *Preconditions:*
102
+
103
+ - `T` meets the *Cpp17MoveConstructible* ([[cpp17.moveconstructible]])
104
+ requirements.
105
+ - Neither `unary_op` nor `binary_op` invalidates subranges, nor modifies
106
+ elements in the range \[`first`, `last`\].
107
 
108
  *Returns:*
109
 
110
  ``` cpp
111
  GENERALIZED_SUM(binary_op, init, unary_op(*i), ...)