From Jason Turner

[alg.foreach]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp3f9zrler/{from.md → to.md} +66 -5
tmp/tmp3f9zrler/{from.md → to.md} RENAMED
@@ -78,10 +78,43 @@ the range \[`first`, `last`), starting from `first` and proceeding to
78
  *Remarks:* If `f` returns a result, the result is ignored.
79
 
80
  [*Note 6*: The overloads in namespace `ranges` require `Fun` to model
81
  `copy_constructible`. — *end note*]
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  ``` cpp
84
  template<class InputIterator, class Size, class Function>
85
  constexpr InputIterator for_each_n(InputIterator first, Size n, Function f);
86
  ```
87
 
@@ -89,17 +122,17 @@ template<class InputIterator, class Size, class Function>
89
  type [[conv.integral]], [[class.conv]].
90
 
91
  *Preconditions:* `n >= 0` is `true`. `Function` meets the
92
  *Cpp17MoveConstructible* requirements.
93
 
94
- [*Note 7*: `Function` need not meet the requirements of
95
  *Cpp17CopyConstructible*. — *end note*]
96
 
97
  *Effects:* Applies `f` to the result of dereferencing every iterator in
98
  the range \[`first`, `first + n`) in order.
99
 
100
- [*Note 8*: If the type of `first` meets the requirements of a mutable
101
  iterator, `f` can apply non-constant functions through the dereferenced
102
  iterator. — *end note*]
103
 
104
  *Returns:* `first + n`.
105
 
@@ -118,11 +151,11 @@ type [[conv.integral]], [[class.conv]].
118
  *Cpp17CopyConstructible* requirements.
119
 
120
  *Effects:* Applies `f` to the result of dereferencing every iterator in
121
  the range \[`first`, `first + n`).
122
 
123
- [*Note 9*: If the type of `first` meets the requirements of a mutable
124
  iterator, `f` can apply non-constant functions through the dereferenced
125
  iterator. — *end note*]
126
 
127
  *Returns:* `first + n`.
128
 
@@ -141,15 +174,43 @@ template<input_iterator I, class Proj = identity,
141
  *Preconditions:* `n >= 0` is `true`.
142
 
143
  *Effects:* Calls `invoke(f, invoke(proj, *i))` for every iterator `i` in
144
  the range \[`first`, `first + n`) in order.
145
 
146
- [*Note 10*: If the result of `invoke(proj, *i)` is a mutable reference,
147
  `f` can apply non-constant functions. — *end note*]
148
 
149
  *Returns:* `{first + n, std::move(f)}`.
150
 
151
  *Remarks:* If `f` returns a result, the result is ignored.
152
 
153
- [*Note 11*: The overload in namespace `ranges` requires `Fun` to model
154
  `copy_constructible`. — *end note*]
155
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  *Remarks:* If `f` returns a result, the result is ignored.
79
 
80
  [*Note 6*: The overloads in namespace `ranges` require `Fun` to model
81
  `copy_constructible`. — *end note*]
82
 
83
+ ``` cpp
84
+ template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
85
+ class Proj = identity,
86
+ indirectly_unary_invocable<projected<I, Proj>> Fun>
87
+ I ranges::for_each(Ep&& exec, I first, S last, Fun f, Proj proj = {});
88
+ template<execution-policy Ep, sized-random-access-range R, class Proj = identity,
89
+ indirectly_unary_invocable<projected<iterator_t<R>, Proj>> Fun>
90
+ borrowed_iterator_t<R>
91
+ ranges::for_each(Ep&& exec, R&& r, Fun f, Proj proj = {});
92
+ ```
93
+
94
+ *Effects:* Calls `invoke(f, invoke(proj, *i))` for every iterator `i` in
95
+ the range \[`first`, `last`).
96
+
97
+ [*Note 7*: If the result of `invoke(proj, *i)` is a mutable reference,
98
+ `f` can apply non-constant functions. — *end note*]
99
+
100
+ *Returns:* `last`.
101
+
102
+ *Complexity:* Applies `f` and `proj` exactly `last - first` times.
103
+
104
+ *Remarks:*
105
+
106
+ - If `f` returns a result, the result is ignored.
107
+ - Implementations do not have the freedom granted under
108
+ [[algorithms.parallel.exec]] to make arbitrary copies of elements from
109
+ the input sequence.
110
+ - `f` may modify objects via its arguments [[algorithms.parallel.user]].
111
+
112
+ [*Note 8*: Does not return a copy of its `Fun` parameter, since
113
+ parallelization often does not permit efficient state
114
+ accumulation. — *end note*]
115
+
116
  ``` cpp
117
  template<class InputIterator, class Size, class Function>
118
  constexpr InputIterator for_each_n(InputIterator first, Size n, Function f);
119
  ```
120
 
 
122
  type [[conv.integral]], [[class.conv]].
123
 
124
  *Preconditions:* `n >= 0` is `true`. `Function` meets the
125
  *Cpp17MoveConstructible* requirements.
126
 
127
+ [*Note 9*: `Function` need not meet the requirements of
128
  *Cpp17CopyConstructible*. — *end note*]
129
 
130
  *Effects:* Applies `f` to the result of dereferencing every iterator in
131
  the range \[`first`, `first + n`) in order.
132
 
133
+ [*Note 10*: If the type of `first` meets the requirements of a mutable
134
  iterator, `f` can apply non-constant functions through the dereferenced
135
  iterator. — *end note*]
136
 
137
  *Returns:* `first + n`.
138
 
 
151
  *Cpp17CopyConstructible* requirements.
152
 
153
  *Effects:* Applies `f` to the result of dereferencing every iterator in
154
  the range \[`first`, `first + n`).
155
 
156
+ [*Note 11*: If the type of `first` meets the requirements of a mutable
157
  iterator, `f` can apply non-constant functions through the dereferenced
158
  iterator. — *end note*]
159
 
160
  *Returns:* `first + n`.
161
 
 
174
  *Preconditions:* `n >= 0` is `true`.
175
 
176
  *Effects:* Calls `invoke(f, invoke(proj, *i))` for every iterator `i` in
177
  the range \[`first`, `first + n`) in order.
178
 
179
+ [*Note 12*: If the result of `invoke(proj, *i)` is a mutable reference,
180
  `f` can apply non-constant functions. — *end note*]
181
 
182
  *Returns:* `{first + n, std::move(f)}`.
183
 
184
  *Remarks:* If `f` returns a result, the result is ignored.
185
 
186
+ [*Note 13*: The overload in namespace `ranges` requires `Fun` to model
187
  `copy_constructible`. — *end note*]
188
 
189
+ ``` cpp
190
+ template<execution-policy Ep, random_access_iterator I, class Proj = identity,
191
+ indirectly_unary_invocable<projected<I, Proj>> Fun>
192
+ I ranges::for_each_n(Ep&& exec, I first, iter_difference_t<I> n, Fun f, Proj proj = {});
193
+ ```
194
+
195
+ *Preconditions:* `n >= 0` is `true`.
196
+
197
+ *Effects:* Calls `invoke(f, invoke(proj, *i))` for every iterator `i` in
198
+ the range \[`first`, `first + n`).
199
+
200
+ [*Note 14*: If the result of `invoke(proj, *i)` is a mutable reference,
201
+ `f` can apply non-constant functions. — *end note*]
202
+
203
+ *Returns:* `first + n`.
204
+
205
+ *Remarks:*
206
+
207
+ - If `f` returns a result, the result is ignored.
208
+ - Implementations do not have the freedom granted under
209
+ [[algorithms.parallel.exec]] to make arbitrary copies of elements from
210
+ the input sequence.
211
+ - `f` may modify objects via its arguments [[algorithms.parallel.user]].
212
+
213
+ [*Note 15*: Does not return a copy of its `Fun` parameter, since
214
+ parallelization often does not permit efficient state
215
+ accumulation. — *end note*]
216
+