From Jason Turner

[adjacent.difference]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp0d_p3els/{from.md → to.md} +35 -38
tmp/tmp0d_p3els/{from.md → to.md} RENAMED
@@ -1,67 +1,64 @@
1
  ### Adjacent difference <a id="adjacent.difference">[[adjacent.difference]]</a>
2
 
3
  ``` cpp
4
  template<class InputIterator, class OutputIterator>
5
- OutputIterator
6
  adjacent_difference(InputIterator first, InputIterator last,
7
  OutputIterator result);
8
  template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
9
  ForwardIterator2
10
  adjacent_difference(ExecutionPolicy&& exec,
11
- ForwardIterator1 first, ForwardIterator1 last,
12
- ForwardIterator2 result);
13
 
14
  template<class InputIterator, class OutputIterator, class BinaryOperation>
15
- OutputIterator
16
  adjacent_difference(InputIterator first, InputIterator last,
17
- OutputIterator result,
18
- BinaryOperation binary_op);
19
  template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
20
  class BinaryOperation>
21
  ForwardIterator2
22
  adjacent_difference(ExecutionPolicy&& exec,
23
  ForwardIterator1 first, ForwardIterator1 last,
24
- ForwardIterator2 result,
25
- BinaryOperation binary_op);
26
  ```
27
 
28
- *Requires:*
29
-
30
- - For the overloads with no `ExecutionPolicy`, `InputIterator`’s value
31
- type shall be `MoveAssignable` (Table  [[tab:moveassignable]]) and
32
- shall be constructible from the type of `*first`. `acc` (defined
33
- below) shall be writable ([[iterator.requirements.general]]) to the
34
- `result` output iterator. The result of the expression `val - acc` or
35
- `binary_op(val, acc)` shall be writable to the `result` output
36
- iterator.
37
- - For the overloads with an `ExecutionPolicy`, the value type of
38
- `ForwardIterator1` shall be `CopyConstructible`
39
- (Table  [[tab:copyconstructible]]), constructible from the expression
40
- `*first - *first` or `binary_op(*first, *first)`, and assignable to
41
- the value type of `ForwardIterator2`.
 
 
 
 
 
42
  - For all overloads, in the ranges \[`first`, `last`\] and \[`result`,
43
- `result + (last - first)`\], `binary_op` shall neither modify elements
44
- nor invalidate iterators or subranges.[^17]
45
 
46
  *Effects:* For the overloads with no `ExecutionPolicy` and a non-empty
47
- range, the function creates an accumulator `acc` whose type is
48
- `InputIterator`’s value type, initializes it with `*first`, and assigns
49
- the result to `*result`. For every iterator `i` in \[`first + 1`,
50
- `last`) in order, creates an object `val` whose type is
51
- `InputIterator`’s value type, initializes it with `*i`, computes
52
- `val - acc` or `binary_op(val, acc)`, assigns the result to
53
  `*(result + (i - first))`, and move assigns from `val` to `acc`.
54
 
55
- For the overloads with an `ExecutionPolicy` and a non-empty range, first
56
- the function creates an object whose type is `ForwardIterator1`’s value
57
- type, initializes it with `*first`, and assigns the result to `*result`.
58
- Then for every `d` in \[`1`, `last - first - 1`\], creates an object
59
- `val` whose type is `ForwardIterator1`’s value type, initializes it with
60
- `*(first + d) - *(first + d - 1)` or
61
- `binary_op(*(first + d), *(first + d - 1))`, and assigns the result to
62
- `*(result + d)`.
63
 
64
  *Returns:* `result + (last - first)`.
65
 
66
  *Complexity:* Exactly `(last - first) - 1` applications of the binary
67
  operation.
 
1
  ### Adjacent difference <a id="adjacent.difference">[[adjacent.difference]]</a>
2
 
3
  ``` cpp
4
  template<class InputIterator, class OutputIterator>
5
+ constexpr OutputIterator
6
  adjacent_difference(InputIterator first, InputIterator last,
7
  OutputIterator result);
8
  template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
9
  ForwardIterator2
10
  adjacent_difference(ExecutionPolicy&& exec,
11
+ ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 result);
 
12
 
13
  template<class InputIterator, class OutputIterator, class BinaryOperation>
14
+ constexpr OutputIterator
15
  adjacent_difference(InputIterator first, InputIterator last,
16
+ OutputIterator result, BinaryOperation binary_op);
 
17
  template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
18
  class BinaryOperation>
19
  ForwardIterator2
20
  adjacent_difference(ExecutionPolicy&& exec,
21
  ForwardIterator1 first, ForwardIterator1 last,
22
+ ForwardIterator2 result, BinaryOperation binary_op);
 
23
  ```
24
 
25
+ Let `T` be the value type of `decltype(first)`. For the overloads that
26
+ do not take an argument `binary_op`, let `binary_op` be an lvalue that
27
+ denotes an object of type `minus<>`.
28
+
29
+ *Mandates:*
30
+
31
+ - For the overloads with no `ExecutionPolicy`, `T` is constructible from
32
+ `*first`. `acc` (defined below) is
33
+ writable [[iterator.requirements.general]] to the `result` output
34
+ iterator. The result of the expression
35
+ `binary_op(val, std::move(acc))` is writable to `result`.
36
+ - For the overloads with an `ExecutionPolicy`, the result of the
37
+ expressions `binary_op(*first, *first)` and `*first` are writable to
38
+ `result`.
39
+
40
+ *Preconditions:*
41
+
42
+ - For the overloads with no `ExecutionPolicy`, `T` meets the
43
+ *Cpp17MoveAssignable* ([[cpp17.moveassignable]]) requirements.
44
  - For all overloads, in the ranges \[`first`, `last`\] and \[`result`,
45
+ `result + (last - first)`\], `binary_op` neither modifies elements nor
46
+ invalidate iterators or subranges. [^10]
47
 
48
  *Effects:* For the overloads with no `ExecutionPolicy` and a non-empty
49
+ range, the function creates an accumulator `acc` of type `T`,
50
+ initializes it with `*first`, and assigns the result to `*result`. For
51
+ every iterator `i` in \[`first + 1`, `last`) in order, creates an object
52
+ `val` whose type is `T`, initializes it with `*i`, computes
53
+ `binary_op(val, std::move(acc))`, assigns the result to
 
54
  `*(result + (i - first))`, and move assigns from `val` to `acc`.
55
 
56
+ For the overloads with an `ExecutionPolicy` and a non-empty range,
57
+ performs `*result = *first`. Then, for every `d` in
58
+ `[1, last - first - 1]`, performs
59
+ `*(result + d) = binary_op(*(first + d), *(first + (d - 1)))`.
 
 
 
 
60
 
61
  *Returns:* `result + (last - first)`.
62
 
63
  *Complexity:* Exactly `(last - first) - 1` applications of the binary
64
  operation.