tabulate_output_iterator#
-
template<class _Fn, class _Index>
class tabulate_output_iterator# tabulate_output_iterator
is a special kind of output iterator which, whenever a value is assigned to a dereferenced iterator, calls the given callable with the index that corresponds to the offset of the dereferenced iterator and the assigned value.The following code snippet demonstrates how to create a
tabulate_output_iterator
which prints the index and the assigned value.#include <cuda/iterator> struct print_op { __host__ __device__ void operator()(int index, float value) const { printf("%d: %f\n", index, value); } }; int main() { auto tabulate_it = cuda::make_tabulate_output_iterator(print_op{}); tabulate_it[0] = 1.0f; // prints: 0: 1.0 tabulate_it[1] = 3.0f; // prints: 1: 3.0 tabulate_it[9] = 5.0f; // prints: 9: 5.0 }
Public Types
-
using iterator_concept = ::cuda::std::random_access_iterator_tag#
-
using iterator_category = ::cuda::std::random_access_iterator_tag#
-
using value_type = void#
-
using pointer = void#
-
using reference = void#
Public Functions
-
template<class _Fn2 = _Fn, ::cuda::std::enable_if_t<::cuda::std::default_initializable<_Fn2>, int> = 0>
inline constexpr tabulate_output_iterator(
- inline constexpr tabulate_output_iterator( ) noexcept(::cuda::std::is_nothrow_move_constructible_v<_Fn>)#
Constructs a
tabulate_output_iterator
with a given functor and an optional index.- Parameters:
__func – the output function
__index – the position in the output sequence
-
inline constexpr difference_type index() const noexcept#
Returns the stored index.
-
inline constexpr auto operator*() const noexcept#
Dereferences the
tabulate_output_iterator
.- Returns:
A proxy that applies the stored function and index on assignment
-
inline constexpr auto operator*() noexcept#
Dereferences the
tabulate_output_iterator
.- Returns:
A proxy that applies the stored function and index on assignment
-
inline constexpr auto operator[](difference_type __n) const noexcept#
Subscripts the
tabulate_output_iterator
with a given offset.- Parameters:
__n – The additional offset to advance the stored index
- Returns:
A proxy that applies the stored function and index on assignment
-
inline constexpr auto operator[](difference_type __n) noexcept#
Subscripts the
tabulate_output_iterator
with a given offset.- Parameters:
__n – The additional offset to advance the stored index
- Returns:
A proxy that applies the stored function and index on assignment
-
inline constexpr tabulate_output_iterator &operator++() noexcept#
Increments the
tabulate_output_iterator
by incrementing the stored index.
- inline constexpr tabulate_output_iterator operator++(
- int,
Increments the
tabulate_output_iterator
by incrementing the stored index.
-
inline constexpr tabulate_output_iterator &operator--() noexcept#
Decrements the
tabulate_output_iterator
by decrementing the stored index.
- inline constexpr tabulate_output_iterator operator--(
- int,
Decrements the
tabulate_output_iterator
by decrementing the stored index.
- inline constexpr tabulate_output_iterator operator+(
- difference_type __n,
Returns a copy of this
tabulate_output_iterator
advanced a given number of elements.- Parameters:
__n – The number of elements to advance
- inline constexpr tabulate_output_iterator &operator+=(
- difference_type __n,
Advances the
tabulate_output_iterator
by a given number of elements.- Parameters:
__n – The number of elements to advance
- inline constexpr tabulate_output_iterator operator-(
- difference_type __n,
Returns a copy of this
tabulate_output_iterator
decremented a given number of elements.- Parameters:
__n – The number of elements to decremented
- inline constexpr tabulate_output_iterator &operator-=(
- difference_type __n,
Decrements the
tabulate_output_iterator
by a given number of elements.- Parameters:
__n – The number of elements to decrement
Friends
- inline friend constexpr tabulate_output_iterator operator+(
- difference_type __n,
- const tabulate_output_iterator &__iter,
Returns a copy of a
tabulate_output_iterator
advanced a given number of elements.- Parameters:
__n – The number of elements to advance
__iter – The original
tabulate_output_iterator
- inline friend constexpr difference_type operator-(
- const tabulate_output_iterator &__lhs,
- const tabulate_output_iterator &__rhs,
Returns the distance between two
tabulate_output_iterator
‘s.
- inline friend constexpr bool operator==(
- const tabulate_output_iterator &__lhs,
- const tabulate_output_iterator &__rhs,
Compares two
tabulate_output_iterator
for equality by comparing their indices.
- inline friend constexpr bool operator<(
- const tabulate_output_iterator &__lhs,
- const tabulate_output_iterator &__rhs,
Compares two
tabulate_output_iterator
for less than by comparing their indices.
- inline friend constexpr bool operator<=(
- const tabulate_output_iterator &__lhs,
- const tabulate_output_iterator &__rhs,
Compares two
tabulate_output_iterator
for less equal by comparing their indices.
- inline friend constexpr bool operator>(
- const tabulate_output_iterator &__lhs,
- const tabulate_output_iterator &__rhs,
Compares two
tabulate_output_iterator
for greater than by comparing their indices.
- inline friend constexpr bool operator>=(
- const tabulate_output_iterator &__lhs,
- const tabulate_output_iterator &__rhs,
Compares two
tabulate_output_iterator
for greater equal by comparing their indices.
-
template<class _Fn, class _Integer = ::cuda::std::ptrdiff_t>
inline constexpr auto make_tabulate_output_iterator(
)# Creates a
tabulate_output_iterator
from an output function and an optional index.- Parameters:
__func – The output function
__index – The index of the
tabulate_output_iterator
within a range. The default index is0
.
- Returns:
A new
tabulate_output_iterator
with__index
as the counter.
-
using iterator_concept = ::cuda::std::random_access_iterator_tag#