From Jason Turner

[inclusive.scan]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp00x0ttca/{from.md → to.md} +36 -27
tmp/tmp00x0ttca/{from.md → to.md} RENAMED
@@ -1,10 +1,11 @@
1
  ### Inclusive scan <a id="inclusive.scan">[[inclusive.scan]]</a>
2
 
3
  ``` cpp
4
  template<class InputIterator, class OutputIterator>
5
- OutputIterator inclusive_scan(InputIterator first, InputIterator last,
 
6
  OutputIterator result);
7
  ```
8
 
9
  *Effects:* Equivalent to:
10
 
@@ -12,11 +13,12 @@ template<class InputIterator, class OutputIterator>
12
  return inclusive_scan(first, last, result, plus<>());
13
  ```
14
 
15
  ``` cpp
16
  template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
17
- ForwardIterator2 inclusive_scan(ExecutionPolicy&& exec,
 
18
  ForwardIterator1 first, ForwardIterator1 last,
19
  ForwardIterator2 result);
20
  ```
21
 
22
  *Effects:* Equivalent to:
@@ -25,43 +27,50 @@ template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
25
  return inclusive_scan(std::forward<ExecutionPolicy>(exec), first, last, result, plus<>());
26
  ```
27
 
28
  ``` cpp
29
  template<class InputIterator, class OutputIterator, class BinaryOperation>
30
- OutputIterator inclusive_scan(InputIterator first, InputIterator last,
31
- OutputIterator result,
32
- BinaryOperation binary_op);
33
  template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
34
  class BinaryOperation>
35
- ForwardIterator2 inclusive_scan(ExecutionPolicy&& exec,
 
36
  ForwardIterator1 first, ForwardIterator1 last,
37
- ForwardIterator2 result,
38
- BinaryOperation binary_op);
39
 
40
  template<class InputIterator, class OutputIterator, class BinaryOperation, class T>
41
- OutputIterator inclusive_scan(InputIterator first, InputIterator last,
42
- OutputIterator result,
43
- BinaryOperation binary_op, T init);
44
  template<class ExecutionPolicy,
45
  class ForwardIterator1, class ForwardIterator2, class BinaryOperation, class T>
46
- ForwardIterator2 inclusive_scan(ExecutionPolicy&& exec,
 
47
  ForwardIterator1 first, ForwardIterator1 last,
48
- ForwardIterator2 result,
49
- BinaryOperation binary_op, T init);
50
  ```
51
 
52
- *Requires:*
53
-
54
- - If `init` is provided, `T` shall be `MoveConstructible`
55
- (Table  [[tab:moveconstructible]]); otherwise, `ForwardIterator1`’s
56
- value type shall be `MoveConstructible`.
57
- - If `init` is provided, all of `binary_op(init, init)`,
58
- `binary_op(init, *first)`, and `binary_op(*first, *first)` shall be
59
- convertible to `T`; otherwise, `binary_op(*first, *first)` shall be
60
- convertible to `ForwardIterator1`’s value type.
61
- - `binary_op` shall neither invalidate iterators or subranges, nor
62
- modify elements in the ranges \[`first`, `last`\] or \[`result`,
 
 
 
 
 
 
 
63
  `result + (last - first)`\].
64
 
65
  *Effects:* For each integer `K` in \[`0`, `last - first`) assigns
66
  through `result + K` the value of
67
 
@@ -78,9 +87,9 @@ through `result + K` the value of
78
  *Complexity:* 𝑂(`last - first`) applications of `binary_op`.
79
 
80
  *Remarks:* `result` may be equal to `first`.
81
 
82
  [*Note 1*: The difference between `exclusive_scan` and `inclusive_scan`
83
- is that `inclusive_scan` includes the `i`th input element in the `i`th
84
- sum. If `binary_op` is not mathematically associative, the behavior of
85
  `inclusive_scan` may be nondeterministic. — *end note*]
86
 
 
1
  ### Inclusive scan <a id="inclusive.scan">[[inclusive.scan]]</a>
2
 
3
  ``` cpp
4
  template<class InputIterator, class OutputIterator>
5
+ constexpr OutputIterator
6
+ inclusive_scan(InputIterator first, InputIterator last,
7
  OutputIterator result);
8
  ```
9
 
10
  *Effects:* Equivalent to:
11
 
 
13
  return inclusive_scan(first, last, result, plus<>());
14
  ```
15
 
16
  ``` cpp
17
  template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
18
+ ForwardIterator2
19
+ inclusive_scan(ExecutionPolicy&& exec,
20
  ForwardIterator1 first, ForwardIterator1 last,
21
  ForwardIterator2 result);
22
  ```
23
 
24
  *Effects:* Equivalent to:
 
27
  return inclusive_scan(std::forward<ExecutionPolicy>(exec), first, last, result, plus<>());
28
  ```
29
 
30
  ``` cpp
31
  template<class InputIterator, class OutputIterator, class BinaryOperation>
32
+ constexpr OutputIterator
33
+ inclusive_scan(InputIterator first, InputIterator last,
34
+ OutputIterator result, BinaryOperation binary_op);
35
  template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
36
  class BinaryOperation>
37
+ ForwardIterator2
38
+ inclusive_scan(ExecutionPolicy&& exec,
39
  ForwardIterator1 first, ForwardIterator1 last,
40
+ ForwardIterator2 result, BinaryOperation binary_op);
 
41
 
42
  template<class InputIterator, class OutputIterator, class BinaryOperation, class T>
43
+ constexpr OutputIterator
44
+ inclusive_scan(InputIterator first, InputIterator last,
45
+ OutputIterator result, BinaryOperation binary_op, T init);
46
  template<class ExecutionPolicy,
47
  class ForwardIterator1, class ForwardIterator2, class BinaryOperation, class T>
48
+ ForwardIterator2
49
+ inclusive_scan(ExecutionPolicy&& exec,
50
  ForwardIterator1 first, ForwardIterator1 last,
51
+ ForwardIterator2 result, BinaryOperation binary_op, T init);
 
52
  ```
53
 
54
+ Let `U` be the value type of `decltype(first)`.
55
+
56
+ *Mandates:* If `init` is provided, all of
57
+
58
+ - `binary_op(init, init)`,
59
+ - `binary_op(init, *first)`, and
60
+ - `binary_op(*first, *first)`
61
+
62
+ are convertible to `T`; otherwise, `binary_op(*first, *first)` is
63
+ convertible to `U`.
64
+
65
+ *Preconditions:*
66
+
67
+ - If `init` is provided, `T` meets the *Cpp17MoveConstructible*
68
+ ([[cpp17.moveconstructible]]) requirements; otherwise, `U` meets the
69
+ *Cpp17MoveConstructible* requirements.
70
+ - `binary_op` neither invalidates iterators or subranges, nor modifies
71
+ elements in the ranges \[`first`, `last`\] or \[`result`,
72
  `result + (last - first)`\].
73
 
74
  *Effects:* For each integer `K` in \[`0`, `last - first`) assigns
75
  through `result + K` the value of
76
 
 
87
  *Complexity:* 𝑂(`last - first`) applications of `binary_op`.
88
 
89
  *Remarks:* `result` may be equal to `first`.
90
 
91
  [*Note 1*: The difference between `exclusive_scan` and `inclusive_scan`
92
+ is that `inclusive_scan` includes the iᵗʰ input element in the iᵗʰ sum.
93
+ If `binary_op` is not mathematically associative, the behavior of
94
  `inclusive_scan` may be nondeterministic. — *end note*]
95