@@ -221,20 +221,24 @@ struct contiguous_iterator_traits
221
221
222
222
using raw_pointer = typename thrust::detail::pointer_traits<decltype(&*std::declval<Iterator>())>::raw_pointer;
223
223
};
224
+ } // namespace detail
224
225
225
- template <typename Iterator>
226
- using contiguous_iterator_raw_pointer_t = typename contiguous_iterator_traits<Iterator>::raw_pointer;
226
+ // ! Converts a contiguous iterator type to its underlying raw pointer type.
227
+ template <typename ContiguousIterator>
228
+ using unwrap_contiguous_iterator_t = typename detail::contiguous_iterator_traits<ContiguousIterator>::raw_pointer;
227
229
228
- // Converts a contiguous iterator to a raw pointer:
229
- template <typename Iterator>
230
- _CCCL_HOST_DEVICE contiguous_iterator_raw_pointer_t <Iterator> contiguous_iterator_raw_pointer_cast (Iterator it)
230
+ // ! Converts a contiguous iterator to its underlying raw pointer.
231
+ template <typename ContiguousIterator>
232
+ _CCCL_HOST_DEVICE auto unwrap_contiguous_iterator (ContiguousIterator it)
233
+ -> unwrap_contiguous_iterator_t<ContiguousIterator>
231
234
{
232
- static_assert (thrust::is_contiguous_iterator<Iterator>::value,
233
- " contiguous_iterator_raw_pointer_cast called with "
234
- " non-contiguous iterator." );
235
+ static_assert (thrust::is_contiguous_iterator<ContiguousIterator>::value,
236
+ " unwrap_contiguous_iterator called with non-contiguous iterator." );
235
237
return thrust::raw_pointer_cast (&*it);
236
238
}
237
239
240
+ namespace detail
241
+ {
238
242
// Implementation for non-contiguous iterators -- passthrough.
239
243
template <typename Iterator, bool IsContiguous = thrust::is_contiguous_iterator<Iterator>::value>
240
244
struct try_unwrap_contiguous_iterator_impl
@@ -251,27 +255,28 @@ struct try_unwrap_contiguous_iterator_impl
251
255
template <typename Iterator>
252
256
struct try_unwrap_contiguous_iterator_impl <Iterator, true /* is_contiguous*/ >
253
257
{
254
- using type = contiguous_iterator_raw_pointer_t <Iterator>;
258
+ using type = unwrap_contiguous_iterator_t <Iterator>;
255
259
256
260
static _CCCL_HOST_DEVICE type get (Iterator it)
257
261
{
258
- return contiguous_iterator_raw_pointer_cast (it);
262
+ return unwrap_contiguous_iterator (it);
259
263
}
260
264
};
265
+ } // namespace detail
261
266
267
+ // ! Takes an iterator type and, if it is contiguous, yields the raw pointer type it represents. Otherwise returns the
268
+ // ! iterator type unmodified.
262
269
template <typename Iterator>
263
- using try_unwrap_contiguous_iterator_return_t = typename try_unwrap_contiguous_iterator_impl<Iterator>::type;
270
+ using try_unwrap_contiguous_iterator_t = typename detail:: try_unwrap_contiguous_iterator_impl<Iterator>::type;
264
271
265
- // Casts to a raw pointer if iterator is marked as contiguous, otherwise returns
266
- // the input iterator.
272
+ // ! Takes an iterator and, if it is contiguous, unwraps it to the raw pointer it represents. Otherwise returns the
273
+ // ! iterator unmodified .
267
274
template <typename Iterator>
268
- _CCCL_HOST_DEVICE try_unwrap_contiguous_iterator_return_t <Iterator> try_unwrap_contiguous_iterator (Iterator it)
275
+ _CCCL_HOST_DEVICE auto try_unwrap_contiguous_iterator (Iterator it) -> try_unwrap_contiguous_iterator_t<Iterator>
269
276
{
270
- return try_unwrap_contiguous_iterator_impl<Iterator>::get (it);
277
+ return detail:: try_unwrap_contiguous_iterator_impl<Iterator>::get (it);
271
278
}
272
279
273
- } // namespace detail
274
-
275
280
/* ! \endcond
276
281
*/
277
282
0 commit comments