From Jason Turner

[alg.copy]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmppawa5pei/{from.md → to.md} +78 -21
tmp/tmppawa5pei/{from.md → to.md} RENAMED
@@ -29,25 +29,43 @@ range \[`result`, `result + `N) starting from `first` and proceeding to
29
 
30
  *Complexity:* Exactly N assignments.
31
 
32
  ``` cpp
33
  template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
34
- ForwardIterator2 copy(ExecutionPolicy&& policy,
35
  ForwardIterator1 first, ForwardIterator1 last,
36
  ForwardIterator2 result);
 
 
 
 
 
 
 
 
 
 
37
  ```
38
 
 
 
 
 
 
39
  *Preconditions:* The ranges \[`first`, `last`) and \[`result`,
40
- `result + (last - first)`) do not overlap.
41
 
42
- *Effects:* Copies elements in the range \[`first`, `last`) into the
43
- range \[`result`, `result + (last - first)`). For each non-negative
44
- integer `n < (last - first)`, performs `*(result + n) = *(first + n)`.
45
 
46
- *Returns:* `result + (last - first)`.
47
 
48
- *Complexity:* Exactly `last - first` assignments.
 
 
 
49
 
50
  ``` cpp
51
  template<class InputIterator, class Size, class OutputIterator>
52
  constexpr OutputIterator copy_n(InputIterator first, Size n,
53
  OutputIterator result);
@@ -58,13 +76,24 @@ template<class ExecutionPolicy, class ForwardIterator1, class Size, class Forwar
58
 
59
  template<input_iterator I, weakly_incrementable O>
60
  requires indirectly_copyable<I, O>
61
  constexpr ranges::copy_n_result<I, O>
62
  ranges::copy_n(I first, iter_difference_t<I> n, O result);
 
 
 
 
 
 
63
  ```
64
 
65
- Let N be max(0, `n`).
 
 
 
 
 
66
 
67
  *Mandates:* The type `Size` is convertible to an integral
68
  type [[conv.integral]], [[class.conv]].
69
 
70
  *Effects:* For each non-negative integer i < N, performs
@@ -95,38 +124,66 @@ template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj
95
  template<input_range R, weakly_incrementable O, class Proj = identity,
96
  indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
97
  requires indirectly_copyable<iterator_t<R>, O>
98
  constexpr ranges::copy_if_result<borrowed_iterator_t<R>, O>
99
  ranges::copy_if(R&& r, O result, Pred pred, Proj proj = {});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  ```
101
 
102
- Let E be:
103
 
104
  - `bool(pred(*i))` for the overloads in namespace `std`;
105
  - `bool(invoke(pred, invoke(proj, *i)))` for the overloads in namespace
106
- `ranges`,
107
 
108
- and N be the number of iterators `i` in the range \[`first`, `last`) for
109
- which the condition E holds.
 
 
 
 
 
110
 
111
  *Preconditions:* The ranges \[`first`, `last`) and \[`result`,
112
- `result + (last - first)`) do not overlap.
113
 
114
- [*Note 1*: For the overload with an `ExecutionPolicy`, there might be a
115
- performance cost if `iterator_traits<ForwardIterator1>::value_type` is
116
- not *Cpp17MoveConstructible*
117
- ([[cpp17.moveconstructible]]). — *end note*]
 
 
 
118
 
119
- *Effects:* Copies all of the elements referred to by the iterator `i` in
120
- the range \[`first`, `last`) for which E is `true`.
 
121
 
122
  *Returns:*
123
 
124
  - `result + `N for the overloads in namespace `std`.
125
- - `{last, result + `N`}` for the overloads in namespace `ranges`.
 
 
 
 
 
126
 
127
- *Complexity:* Exactly `last - first` applications of the corresponding
128
  predicate and any projection.
129
 
130
  *Remarks:* Stable [[algorithm.stable]].
131
 
132
  ``` cpp
 
29
 
30
  *Complexity:* Exactly N assignments.
31
 
32
  ``` cpp
33
  template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
34
+ ForwardIterator2 copy(ExecutionPolicy&& exec,
35
  ForwardIterator1 first, ForwardIterator1 last,
36
  ForwardIterator2 result);
37
+
38
+ template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
39
+ random_access_iterator O, sized_sentinel_for<O> OutS>
40
+ requires indirectly_copyable<I, O>
41
+ ranges::copy_result<I, O>
42
+ ranges::copy(Ep&& exec, I first, S last, O result, OutS result_last);
43
+ template<execution-policy Ep, sized-random-access-range R, sized-random-access-range OutR>
44
+ requires indirectly_copyable<iterator_t<R>, iterator_t<OutR>>
45
+ ranges::copy_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
46
+ ranges::copy(Ep&& exec, R&& r, OutR&& result_r);
47
  ```
48
 
49
+ Let `result_last` be `result + (last - first)` for the overload in
50
+ namespace `std`.
51
+
52
+ Let N be min(`last - first`, `result_last - result`).
53
+
54
  *Preconditions:* The ranges \[`first`, `last`) and \[`result`,
55
+ `result + `N) do not overlap.
56
 
57
+ *Effects:* Copies elements in the range \[`first`, `first + `N) into the
58
+ range \[`result`, `result + `N). For each non-negative integer n < N,
59
+ performs `*(result + `n`) = *(first + `n`)`.
60
 
61
+ *Returns:*
62
 
63
+ - `result + `N for the overload in namespace `std`.
64
+ - `{first + `N`, result + `N`}` for the overloads in namespace `ranges`.
65
+
66
+ *Complexity:* Exactly N assignments.
67
 
68
  ``` cpp
69
  template<class InputIterator, class Size, class OutputIterator>
70
  constexpr OutputIterator copy_n(InputIterator first, Size n,
71
  OutputIterator result);
 
76
 
77
  template<input_iterator I, weakly_incrementable O>
78
  requires indirectly_copyable<I, O>
79
  constexpr ranges::copy_n_result<I, O>
80
  ranges::copy_n(I first, iter_difference_t<I> n, O result);
81
+
82
+ template<execution-policy Ep, random_access_iterator I, random_access_iterator O,
83
+ sized_sentinel_for<O> OutS>
84
+ requires indirectly_copyable<I, O>
85
+ ranges::copy_n_result<I, O>
86
+ ranges::copy_n(Ep&& exec, I first, iter_difference_t<I> n, O result, OutS result_last);
87
  ```
88
 
89
+ Let M be max(0, `n`).
90
+
91
+ Let `result_last` be `result + `M for the overloads with no parameter
92
+ `result_last`.
93
+
94
+ Let N be min(`result_last - result`, M).
95
 
96
  *Mandates:* The type `Size` is convertible to an integral
97
  type [[conv.integral]], [[class.conv]].
98
 
99
  *Effects:* For each non-negative integer i < N, performs
 
124
  template<input_range R, weakly_incrementable O, class Proj = identity,
125
  indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
126
  requires indirectly_copyable<iterator_t<R>, O>
127
  constexpr ranges::copy_if_result<borrowed_iterator_t<R>, O>
128
  ranges::copy_if(R&& r, O result, Pred pred, Proj proj = {});
129
+
130
+ template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
131
+ random_access_iterator O, sized_sentinel_for<O> OutS,
132
+ class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
133
+ requires indirectly_copyable<I, O>
134
+ ranges::copy_if_result<I, O>
135
+ ranges::copy_if(Ep&& exec, I first, S last, O result, OutS result_last,
136
+ Pred pred, Proj proj = {});
137
+ template<execution-policy Ep, sized-random-access-range R, sized-random-access-range OutR,
138
+ class Proj = identity,
139
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
140
+ requires indirectly_copyable<iterator_t<R>, iterator_t<OutR>>
141
+ ranges::copy_if_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
142
+ ranges::copy_if(Ep&& exec, R&& r, OutR&& result_r, Pred pred, Proj proj = {});
143
  ```
144
 
145
+ Let E(`i`) be:
146
 
147
  - `bool(pred(*i))` for the overloads in namespace `std`;
148
  - `bool(invoke(pred, invoke(proj, *i)))` for the overloads in namespace
149
+ `ranges`.
150
 
151
+ Let:
152
+
153
+ - M be the number of iterators `i` in the range \[`first`, `last`) for
154
+ which the condition E(`i`) holds;
155
+ - `result_last` be `result + `M for the overloads with no parameter
156
+ `result_last` or `result_r`;
157
+ - N be min(M, `result_last - result`).
158
 
159
  *Preconditions:* The ranges \[`first`, `last`) and \[`result`,
160
+ `result + `N) do not overlap.
161
 
162
+ [*Note 1*: For the parallel algorithm overload in namespace `std`,
163
+ there can be a performance cost if
164
+ `iterator_traits<ForwardIterator1>::value_type` does not meet the
165
+ *Cpp17MoveConstructible* ([[cpp17.moveconstructible]]) requirements.
166
+ For the parallel algorithm overloads in namespace `ranges`, there can be
167
+ a performance cost if `iter_value_t<I>` does not model
168
+ `move_constructible`. — *end note*]
169
 
170
+ *Effects:* Copies the first N elements referred to by the iterator `i`
171
+ in the range \[`first`, `last`) for which E(`i`) is `true` into the
172
+ range \[`result`, `result + `N).
173
 
174
  *Returns:*
175
 
176
  - `result + `N for the overloads in namespace `std`.
177
+ - `{last, result + `N`}` for the overloads in namespace `ranges`, if N
178
+ is equal to M.
179
+ - Otherwise, `{j, result_last}` for the overloads in namespace `ranges`,
180
+ where `j` is the iterator in \[`first`, `last`) for which E(`j`) holds
181
+ and there are exactly N iterators `i` in \[`first`, `j`) for which
182
+ E(`i`) holds.
183
 
184
+ *Complexity:* At most `last - first` applications of the corresponding
185
  predicate and any projection.
186
 
187
  *Remarks:* Stable [[algorithm.stable]].
188
 
189
  ``` cpp