strided_iterator#

template<class _Iter, class _Stride = ::cuda::std::iter_difference_t<_Iter>>
class strided_iterator#

A strided_iterator wraps another iterator and advances it by a specified stride each time it is incremented or decremented.

Template Parameters:

Public Types

using iterator_concept = ::cuda::std::random_access_iterator_tag#
using iterator_category = ::cuda::std::random_access_iterator_tag#
using value_type = ::cuda::std::iter_value_t<_Iter>#
using difference_type = ::cuda::std::iter_difference_t<_Iter>#

Public Functions

strided_iterator() = default#

value-initializes both the base iterator and stride

Note

_Iter must be default initializable because it is a random_access_iterator and thereby semiregular _Stride must be integer-like or integral_constant_like which requires default constructability

template<class _Stride2 = _Stride, ::cuda::std::enable_if_t<::cuda::std::__integral_constant_like<_Stride2>, int> = 0>
inline explicit constexpr strided_iterator(
_Iter __iter,
) noexcept(::cuda::std::is_nothrow_move_constructible_v<_Iter> && ::cuda::std::is_nothrow_default_constructible_v<_Stride2>)#

Constructs a strided_iterator from a base iterator.

Note

We cannot construct a strided_iterator with an integer-like stride, because that would value construct to 0 and incrementing the iterator would do nothing.

Parameters:

__iter – The base iterator

inline explicit constexpr strided_iterator(
_Iter __iter,
_Stride __stride,
) noexcept(::cuda::std::is_nothrow_move_constructible_v<_Iter> && ::cuda::std::is_nothrow_move_constructible_v<_Stride>)#

Constructs a strided_iterator from a base iterator and a stride.

Parameters:
  • __iter – The base iterator

  • __stride – The new stride

inline constexpr const _Iter &base() const & noexcept#

Returns a const reference to the stored iterator.

inline constexpr _Iter base(
) && noexcept(::cuda::std::is_nothrow_move_constructible_v<_Iter>)#

Extracts the stored iterator.

inline constexpr difference_type stride(
) const noexcept(__noexcept_stride)#

Returns the current stride as an integral value.

inline constexpr decltype(auto) operator*(
) noexcept(noexcept(*__iter_))#

Dereferences the stored base iterator.

template<class _Iter2 = _Iter, ::cuda::std::enable_if_t<::cuda::std::__dereferenceable<const _Iter2>, int> = 0>
inline constexpr decltype(auto) operator*(
) const noexcept(noexcept(*__iter_))#

Dereferences the stored base iterator.

inline constexpr decltype(auto) operator[](
difference_type __n,
) noexcept(__noexcept_stride && noexcept(__iter_[__n]))#

Subscripts the stored base iterator with a given offset times the stride.

Parameters:

__n – The offset

template<class _Iter2 = _Iter, ::cuda::std::enable_if_t<::cuda::std::__dereferenceable<const _Iter2>, int> = 0>
inline constexpr decltype(auto) operator[](
difference_type __n,
) const noexcept(__noexcept_stride && noexcept(__iter_[__n]))#

Subscripts the stored base iterator with a given offset times the stride.

Parameters:

__n – The offset

inline constexpr strided_iterator &operator++(
) noexcept(__noexcept_stride && noexcept(__iter_ += 1))#

Increments the stored base iterator by the stride.

inline constexpr auto operator++(
int,
) noexcept(noexcept(__noexcept_stride && noexcept(__iter_ += 1)) && ::cuda::std::is_nothrow_copy_constructible_v<_Iter> && ::cuda::std::is_nothrow_copy_constructible_v<_Stride>)#

Increments the stored base iterator by the stride.

inline constexpr strided_iterator &operator--(
) noexcept(__noexcept_stride && noexcept(__iter_ -= 1))#

Decrements the stored base iterator by the stride.

inline constexpr strided_iterator operator--(
int,
) noexcept(noexcept(__noexcept_stride && noexcept(__iter_ -= 1)) && ::cuda::std::is_nothrow_copy_constructible_v<_Iter> && ::cuda::std::is_nothrow_copy_constructible_v<_Stride>)#

Decrements the stored base iterator by the stride.

inline constexpr strided_iterator &operator+=(
difference_type __n,
) noexcept(__noexcept_stride && noexcept(__iter_ += 1))#

Advances a strided_iterator by a given number of steps.

Note

Increments the base iterator by __n times the stride

Parameters:

__n – The number of steps to increment

inline constexpr strided_iterator &operator-=(
difference_type __n,
) noexcept(__noexcept_stride && noexcept(__iter_ -= 1))#

Decrements a strided_iterator by a given number of steps.

Note

Decrements the base iterator by __n times the stride

Parameters:

__n – The number of steps to decrement

Friends

inline friend constexpr strided_iterator operator+(
strided_iterator __iter,
difference_type __n,
) noexcept(noexcept(__iter_ += __n))#

Returns a copy of a strided_iterator incremented by a given number of steps.

Parameters:
  • __iter – The strided_iterator to advance

  • __n – The number of steps to increment

inline friend constexpr strided_iterator operator+(
difference_type __n,
strided_iterator __iter,
) noexcept(noexcept(__iter_ + __n))#

Returns a copy of a strided_iterator incremented by a given number of steps.

Parameters:
  • __n – The number of steps to increment

  • __iter – The strided_iterator to advance

inline friend constexpr strided_iterator operator-(
strided_iterator __iter,
difference_type __n,
) noexcept(noexcept(__iter_ -= __n))#

Returns a copy of a strided_iterator decremented by a given number of steps.

Parameters:
  • __n – The number of steps to decrement

  • __iter – The strided_iterator to decrement

template<class _OtherIter, class _OtherStride>
inline friend constexpr difference_type operator-(
const strided_iterator &__x,
const strided_iterator<_OtherIter, _OtherStride> &__y,
) noexcept(noexcept(::cuda::std::declval<_Iter>() - ::cuda::std::declval<_OtherIter>()))#

Returns distance between two strided_iterator's in units of the stride.

template<class _OtherIter, class _OtherStride>
inline friend constexpr bool operator==(
const strided_iterator &__x,
const strided_iterator<_OtherIter, _OtherStride> &__y,
) noexcept(noexcept(::cuda::std::declval<const _Iter&>() == ::cuda::std::declval<const _OtherIter&>()))#

Compares two strided_iterator's for equality by comparing the stored iterators.

template<class _OtherIter, class _OtherStride>
inline friend constexpr bool operator<(
const strided_iterator &__x,
const strided_iterator<_OtherIter, _OtherStride> &__y,
) noexcept(noexcept(::cuda::std::declval<const _Iter&>() < ::cuda::std::declval<const _OtherIter&>()))#

Compares two strided_iterator's for less than by comparing the stored iterators.

template<class _OtherIter, class _OtherStride>
inline friend constexpr bool operator>(
const strided_iterator &__x,
const strided_iterator<_OtherIter, _OtherStride> &__y,
) noexcept(noexcept(::cuda::std::declval<const _Iter&>() < ::cuda::std::declval<const _OtherIter&>()))#

Compares two strided_iterator's for greater than by comparing the stored iterators.

template<class _OtherIter, class _OtherStride>
inline friend constexpr bool operator<=(
const strided_iterator &__x,
const strided_iterator<_OtherIter, _OtherStride> &__y,
) noexcept(noexcept(::cuda::std::declval<const _Iter&>() < ::cuda::std::declval<const _OtherIter&>()))#

Compares two strided_iterator's for less equal by comparing the stored iterators.

template<class _OtherIter, class _OtherStride>
inline friend constexpr bool operator>=(
const strided_iterator &__x,
const strided_iterator<_OtherIter, _OtherStride> &__y,
) noexcept(noexcept(::cuda::std::declval<const _Iter&>() < ::cuda::std::declval<const _OtherIter&>()))#

Compares two strided_iterator's for greater equal by comparing the stored iterators.

template<class _Stride, class _Iter>
inline constexpr auto make_strided_iterator(
_Iter __iter,
)#

Creates a strided_iterator from a random access iterator.

Parameters:

__iter – The random_access iterator

template<class _Iter, class _Stride>
inline constexpr auto make_strided_iterator(
_Iter __iter,
_Stride __stride,
)#

Creates a strided_iterator from a random access iterator and a stride.

Parameters:
  • __iter – The random_access iterator

  • __stride – The new stride