@@ -47,31 +47,16 @@ _LIBCUDACXX_BEGIN_NAMESPACE_CUDA
47
47
// !
48
48
// ! int main()
49
49
// ! {
50
- // ! thrust::device_vector<int> keys(7), values(7);
51
- // !
52
- // ! keys[0] = 1;
53
- // ! keys[1] = 3;
54
- // ! keys[2] = 3;
55
- // ! keys[3] = 3;
56
- // ! keys[4] = 2;
57
- // ! keys[5] = 2;
58
- // ! keys[6] = 1;
59
- // !
60
- // ! values[0] = 9;
61
- // ! values[1] = 8;
62
- // ! values[2] = 7;
63
- // ! values[3] = 6;
64
- // ! values[4] = 5;
65
- // ! values[5] = 4;
66
- // ! values[6] = 3;
50
+ // ! thrust::device_vector<int> keys{1, 3, 3, 3, 2, 2, 1};
51
+ // ! thrust::device_vector<int> values{9, 8, 7, 6, 5, 4, 3};
67
52
// !
68
53
// ! thrust::device_vector<int> result(4);
69
54
// !
70
55
// ! // we are only interested in the reduced values
71
56
// ! // use discard_iterator to ignore the output keys
72
57
// ! thrust::reduce_by_key(keys.begin(), keys.end(),
73
58
// ! values.begin(),
74
- // ! cuda::make_discard_iterator() ,
59
+ // ! cuda::discard_iterator{} ,
75
60
// ! result.begin());
76
61
// !
77
62
// ! // result is now [9, 21, 9, 3]
@@ -82,7 +67,7 @@ _LIBCUDACXX_BEGIN_NAMESPACE_CUDA
82
67
class discard_iterator
83
68
{
84
69
private:
85
- _CUDA_VSTD::ptrdiff_t __counter_ = 0 ;
70
+ _CUDA_VSTD::ptrdiff_t __index_ = 0 ;
86
71
87
72
struct __discard_proxy
88
73
{
@@ -102,21 +87,21 @@ class discard_iterator
102
87
using pointer = void *;
103
88
using reference = void ;
104
89
105
- // ! @brief Default constructs a \p discard_iterator with a value initialized counter
90
+ // ! @brief Default constructs a \p discard_iterator at index zero
106
91
_CCCL_HIDE_FROM_ABI constexpr discard_iterator () = default;
107
92
108
- // ! @brief Constructs a \p discard_iterator with a given \p __counter
109
- // ! @param __counter The counter used for the discard iterator
93
+ // ! @brief Constructs a \p discard_iterator with a given \p __index
94
+ // ! @param __index The index used for the discard iterator
110
95
_CCCL_TEMPLATE (class _Integer )
111
96
_CCCL_REQUIRES (_CUDA_VSTD::__integer_like<_Integer>)
112
- _LIBCUDACXX_HIDE_FROM_ABI constexpr discard_iterator (_Integer __counter ) noexcept
113
- : __counter_ (static_cast <_CUDA_VSTD::ptrdiff_t >(__counter ))
97
+ _LIBCUDACXX_HIDE_FROM_ABI constexpr discard_iterator (_Integer __index ) noexcept
98
+ : __index_ (static_cast <_CUDA_VSTD::ptrdiff_t >(__index ))
114
99
{}
115
100
116
- // ! @brief Returns the stored counter
117
- [[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI constexpr difference_type count () const noexcept
101
+ // ! @brief Returns the stored index
102
+ [[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI constexpr difference_type index () const noexcept
118
103
{
119
- return __counter_ ;
104
+ return __index_ ;
120
105
}
121
106
122
107
// ! @brief Dereferences the \c discard_iterator returning a proxy that discards all values that are assigned to it
@@ -131,41 +116,41 @@ class discard_iterator
131
116
return {};
132
117
}
133
118
134
- // ! @brief Increments the stored counter
119
+ // ! @brief Increments the stored index
135
120
_LIBCUDACXX_HIDE_FROM_ABI constexpr discard_iterator& operator ++() noexcept
136
121
{
137
- ++__counter_ ;
122
+ ++__index_ ;
138
123
return *this ;
139
124
}
140
125
141
- // ! @brief Increments the stored counter
126
+ // ! @brief Increments the stored index
142
127
_LIBCUDACXX_HIDE_FROM_ABI constexpr discard_iterator operator ++(int ) noexcept
143
128
{
144
129
discard_iterator __tmp = *this ;
145
- ++__counter_ ;
130
+ ++__index_ ;
146
131
return __tmp;
147
132
}
148
133
149
- // ! @brief Decrements the stored counter
134
+ // ! @brief Decrements the stored index
150
135
_LIBCUDACXX_HIDE_FROM_ABI constexpr discard_iterator& operator --() noexcept
151
136
{
152
- --__counter_ ;
137
+ --__index_ ;
153
138
return *this ;
154
139
}
155
140
156
- // ! @brief Decrements the stored counter
141
+ // ! @brief Decrements the stored index
157
142
_LIBCUDACXX_HIDE_FROM_ABI constexpr discard_iterator operator --(int ) noexcept
158
143
{
159
144
discard_iterator __tmp = *this ;
160
- --__counter_ ;
145
+ --__index_ ;
161
146
return __tmp;
162
147
}
163
148
164
149
// ! @brief Returns a copy of this \c discard_iterator advanced by \p __n
165
150
// ! @param __n The number of elements to advance
166
151
[[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI constexpr discard_iterator operator +(difference_type __n) const noexcept
167
152
{
168
- return discard_iterator{__counter_ + __n};
153
+ return discard_iterator{__index_ + __n};
169
154
}
170
155
171
156
// ! @brief Returns a copy of \p __x advanced by \p __n
@@ -177,179 +162,178 @@ class discard_iterator
177
162
return __x + __n;
178
163
}
179
164
180
- // ! @brief Advances this \c discard_iterator by \p __n
165
+ // ! @brief Advances the index of this \c discard_iterator by \p __n
181
166
// ! @param __n The number of elements to advance
182
167
_LIBCUDACXX_HIDE_FROM_ABI constexpr discard_iterator& operator +=(difference_type __n) noexcept
183
168
{
184
- __counter_ += __n;
169
+ __index_ += __n;
185
170
return *this ;
186
171
}
187
172
188
173
// ! @brief Returns a copy of this \c discard_iterator decremented by \p __n
189
174
// ! @param __n The number of elements to decrement
190
175
[[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI constexpr discard_iterator operator -(difference_type __n) const noexcept
191
176
{
192
- return discard_iterator{__counter_ - __n};
177
+ return discard_iterator{__index_ - __n};
193
178
}
194
179
195
180
// ! @brief Returns the distance between \p __lhs and \p __rhs
196
181
// ! @param __lhs The left \c discard_iterator
197
182
// ! @param __rhs The right \c discard_iterator
198
- // ! @return __rhs.__counter_ - __lhs.__counter_
183
+ // ! @return __rhs.__index_ - __lhs.__index_
199
184
[[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI friend constexpr difference_type
200
185
operator -(const discard_iterator& __lhs, const discard_iterator& __rhs) noexcept
201
186
{
202
- return __rhs.__counter_ - __lhs.__counter_ ;
187
+ return __rhs.__index_ - __lhs.__index_ ;
203
188
}
204
189
205
190
// ! @brief Returns the distance between \p __lhs a \p default_sentinel
206
191
// ! @param __lhs The left \c discard_iterator
207
- // ! @return -__lhs.__counter_
192
+ // ! @return -__lhs.__index_
208
193
[[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI friend constexpr difference_type
209
194
operator -(const discard_iterator& __lhs, _CUDA_VSTD::default_sentinel_t ) noexcept
210
195
{
211
- return static_cast <difference_type>(-__lhs.__counter_ );
196
+ return static_cast <difference_type>(-__lhs.__index_ );
212
197
}
213
198
214
199
// ! @brief Returns the distance between a \p default_sentinel and \p __rhs
215
200
// ! @param __rhs The right \c discard_iterator
216
- // ! @return __rhs.__coutner_
201
+ // ! @return __rhs.__index_
217
202
[[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI friend constexpr difference_type
218
203
operator -(_CUDA_VSTD::default_sentinel_t , const discard_iterator& __rhs) noexcept
219
204
{
220
- return static_cast <difference_type>(__rhs.__counter_ );
205
+ return static_cast <difference_type>(__rhs.__index_ );
221
206
}
222
207
223
- // ! @brief Decrements the \c discard_iterator by \p __n
208
+ // ! @brief Decrements the index of the \c discard_iterator by \p __n
224
209
// ! @param __n The number of elements to decrement
225
210
_LIBCUDACXX_HIDE_FROM_ABI constexpr discard_iterator& operator -=(difference_type __n) noexcept
226
211
{
227
- __counter_ -= __n;
212
+ __index_ -= __n;
228
213
return *this ;
229
214
}
230
215
231
216
// ! @brief Compares two \c discard_iterator \p __lhs and \p __rhs for equality
232
217
// ! @param __lhs The left \c discard_iterator
233
218
// ! @param __rhs The right \c discard_iterator
234
- // ! @return true if both iterators store the same counter
219
+ // ! @return true if both iterators store the same index
235
220
[[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI friend constexpr bool
236
221
operator ==(const discard_iterator& __lhs, const discard_iterator& __rhs) noexcept
237
222
{
238
- return __lhs.__counter_ == __rhs.__counter_ ;
223
+ return __lhs.__index_ == __rhs.__index_ ;
239
224
}
240
225
241
226
#if _CCCL_STD_VER <= 2017
242
227
// ! @brief Compares two \c discard_iterator \p __lhs and \p __rhs for inequality
243
228
// ! @param __lhs The left \c discard_iterator
244
229
// ! @param __rhs The right \c discard_iterator
245
- // ! @return true if both iterators store different counters
230
+ // ! @return true if both iterators store different indexs
246
231
[[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI friend constexpr bool
247
232
operator !=(const discard_iterator& __lhs, const discard_iterator& __rhs) noexcept
248
233
{
249
- return __lhs.__counter_ != __rhs.__counter_ ;
234
+ return __lhs.__index_ != __rhs.__index_ ;
250
235
}
251
236
#endif // _CCCL_STD_VER <= 2017
252
237
253
238
// ! @brief Compares a \c discard_iterator \p __lhs with \p default_sentinel for equality
254
239
// ! @param __lhs The left \c discard_iterator
255
- // ! @return true if the counter of \p __lhs is zero
240
+ // ! @return true if the index of \p __lhs is zero
256
241
[[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI friend constexpr bool
257
242
operator ==(const discard_iterator& __lhs, _CUDA_VSTD::default_sentinel_t ) noexcept
258
243
{
259
- return __lhs.__counter_ == 0 ;
244
+ return __lhs.__index_ == 0 ;
260
245
}
261
246
262
247
#if _CCCL_STD_VER <= 2017
263
248
// ! @brief Compares a \c discard_iterator \p __rhs with \p default_sentinel for equality
264
249
// ! @param __rhs The right \c discard_iterator
265
- // ! @return true if the counter of \p __rhs is zero
250
+ // ! @return true if the index of \p __rhs is zero
266
251
[[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI friend constexpr bool
267
252
operator ==(_CUDA_VSTD::default_sentinel_t , const discard_iterator& __rhs) noexcept
268
253
{
269
- return __rhs.__counter_ == 0 ;
254
+ return __rhs.__index_ == 0 ;
270
255
}
271
256
272
257
// ! @brief Compares a \c discard_iterator \p __rhs with \p default_sentinel for inequality
273
258
// ! @param __lhs The right \c discard_iterator
274
- // ! @return true if the counter of \p __lhs is not zero
259
+ // ! @return true if the index of \p __lhs is not zero
275
260
[[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI friend constexpr bool
276
261
operator !=(const discard_iterator& __lhs, _CUDA_VSTD::default_sentinel_t ) noexcept
277
262
{
278
- return __lhs.__counter_ != 0 ;
263
+ return __lhs.__index_ != 0 ;
279
264
}
280
265
281
266
// ! @brief Compares a \c discard_iterator \p __rhs with \p default_sentinel for inequality
282
267
// ! @param __rhs The right \c discard_iterator
283
- // ! @return true if the counter of \p __rhs is not zero
268
+ // ! @return true if the index of \p __rhs is not zero
284
269
[[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI friend constexpr bool
285
270
operator !=(_CUDA_VSTD::default_sentinel_t , const discard_iterator& __rhs) noexcept
286
271
{
287
- return __rhs.__counter_ != 0 ;
272
+ return __rhs.__index_ != 0 ;
288
273
}
289
274
#endif // _CCCL_STD_VER <= 2017
290
275
291
276
#if _LIBCUDACXX_HAS_SPACESHIP_OPERATOR()
292
277
// ! @brief Three-way-compares two \c discard_iterator \p __lhs and \p __rhs
293
278
// ! @param __lhs The left \c discard_iterator
294
279
// ! @param __rhs The right \c discard_iterator
295
- // ! @return the three-way ordering of the counters stored by \p __lhs and \p __rhs
280
+ // ! @return the three-way ordering of the indexs stored by \p __lhs and \p __rhs
296
281
[[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI friend constexpr strong_ordering
297
282
operator <=>(const discard_iterator& __lhs, const discard_iterator& __rhs) noexcept
298
283
{
299
- return __lhs.__counter_ <=> __rhs.__counter_ ;
284
+ return __lhs.__index_ <=> __rhs.__index_ ;
300
285
}
301
286
#endif // _LIBCUDACXX_HAS_SPACESHIP_OPERATOR()
302
287
303
288
// ! @brief Compares two \c discard_iterator \p __lhs and \p __rhs for less than
304
289
// ! @param __lhs The left \c discard_iterator
305
290
// ! @param __rhs The right \c discard_iterator
306
- // ! @return true if the counter stored by \p __lhs compares less than the one stored by \p __rhs
291
+ // ! @return true if the index stored by \p __lhs compares less than the one stored by \p __rhs
307
292
[[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI friend constexpr bool
308
293
operator <(const discard_iterator& __lhs, const discard_iterator& __rhs) noexcept
309
294
{
310
- return __lhs.__counter_ < __rhs.__counter_ ;
295
+ return __lhs.__index_ < __rhs.__index_ ;
311
296
}
312
297
313
298
// ! @brief Compares two \c discard_iterator \p __lhs and \p __rhs for less equal
314
299
// ! @param __lhs The left \c discard_iterator
315
300
// ! @param __rhs The right \c discard_iterator
316
- // ! @return true if the counter stored by \p __lhs compares less equal the one stored by \p __rhs
301
+ // ! @return true if the index stored by \p __lhs compares less equal the one stored by \p __rhs
317
302
[[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI friend constexpr bool
318
303
operator <=(const discard_iterator& __lhs, const discard_iterator& __rhs) noexcept
319
304
{
320
- return __lhs.__counter_ <= __rhs.__counter_ ;
305
+ return __lhs.__index_ <= __rhs.__index_ ;
321
306
}
322
307
323
308
// ! @brief Compares two \c discard_iterator \p __lhs and \p __rhs for greater than
324
309
// ! @param __lhs The left \c discard_iterator
325
310
// ! @param __rhs The right \c discard_iterator
326
- // ! @return true if the counter stored by \p __lhs compares less greater the one stored by \p __rhs
311
+ // ! @return true if the index stored by \p __lhs compares less greater the one stored by \p __rhs
327
312
[[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI friend constexpr bool
328
313
operator >(const discard_iterator& __lhs, const discard_iterator& __rhs) noexcept
329
314
{
330
- return __lhs.__counter_ > __rhs.__counter_ ;
315
+ return __lhs.__index_ > __rhs.__index_ ;
331
316
}
332
317
333
318
// ! @brief Compares two \c discard_iterator \p __lhs and \p __rhs for greater equal
334
319
// ! @param __lhs The left \c discard_iterator
335
320
// ! @param __rhs The right \c discard_iterator
336
- // ! @return true if the counter stored by \p __lhs compares greater equal the one stored by \p __rhs
321
+ // ! @return true if the index stored by \p __lhs compares greater equal the one stored by \p __rhs
337
322
[[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI friend constexpr bool
338
323
operator >=(const discard_iterator& __lhs, const discard_iterator& __rhs) noexcept
339
324
{
340
- return __lhs.__counter_ >= __rhs.__counter_ ;
325
+ return __lhs.__index_ >= __rhs.__index_ ;
341
326
}
342
327
};
343
328
344
- // ! @brief Creates a \p discard_iterator from an optional counter.
345
- // ! @param __counter The index of the returned \p discard_iterator within a range. In the default case, the value of
346
- // ! this parameter is \c 0.
347
- // ! @return A new \p discard_iterator with \p __counter as the couner.
329
+ // ! @brief Creates a \p discard_iterator from an optional index.
330
+ // ! @param __index The index of the \p discard_iterator within a range. The default index is \c 0.
331
+ // ! @return A new \p discard_iterator with \p __index as the couner.
348
332
_CCCL_TEMPLATE (class _Integer = _CUDA_VSTD::ptrdiff_t )
349
333
_CCCL_REQUIRES(_CUDA_VSTD::__integer_like<_Integer>)
350
- [[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI constexpr discard_iterator make_discard_iterator(_Integer __counter = 0 )
334
+ [[nodiscard]] _LIBCUDACXX_HIDE_FROM_ABI constexpr discard_iterator make_discard_iterator(_Integer __index = 0 )
351
335
{
352
- return discard_iterator{__counter };
336
+ return discard_iterator{__index };
353
337
}
354
338
355
339
_LIBCUDACXX_END_NAMESPACE_CUDA
0 commit comments