From Jason Turner

[transform.reduce]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpgsvzjy94/{from.md → to.md} +105 -0
tmp/tmpgsvzjy94/{from.md → to.md} RENAMED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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,
31
+ class ForwardIterator1, class ForwardIterator2, class T,
32
+ class BinaryOperation1, class BinaryOperation2>
33
+ T transform_reduce(ExecutionPolicy&& exec,
34
+ ForwardIterator1 first1, ForwardIterator1 last1,
35
+ ForwardIterator2 first2,
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
58
+ GENERALIZED_SUM(binary_op1, init, binary_op2(*i, *(first2 + (i - first1))), ...)
59
+ ```
60
+
61
+ for every iterator `i` in \[`first1`, `last1`).
62
+
63
+ *Complexity:* 𝑂(`last1 - first1`) applications each of `binary_op1` and
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), ...)
96
+ ```
97
+
98
+ for every iterator `i` in \[`first`, `last`).
99
+
100
+ *Complexity:* 𝑂(`last - first`) applications each of `unary_op` and
101
+ `binary_op`.
102
+
103
+ [*Note 1*: `transform_reduce` does not apply `unary_op` to
104
+ `init`. — *end note*]
105
+