rocPRIM
Public Types | Public Member Functions | Friends | List of all members
constant_iterator< ValueType, Difference > Class Template Reference

A random-access input (read-only) iterator which generates a sequence of homogeneous values. More...

#include <constant_iterator.hpp>

Public Types

using value_type = typename std::remove_const< ValueType >::type
 The type of the value that can be obtained by dereferencing the iterator.
 
using reference = value_type
 A reference type of the type iterated over (value_type). More...
 
using pointer = const value_type *
 A pointer type of the type iterated over (value_type). More...
 
using difference_type = Difference
 A type used for identify distance between iterators.
 
using iterator_category = std::random_access_iterator_tag
 The category of the iterator.
 
using self_type = constant_iterator
 

Public Member Functions

ROCPRIM_HOST_DEVICE constant_iterator (const value_type value, const size_t index=0)
 Creates constant_iterator and sets its initial value to value. More...
 
ROCPRIM_HOST_DEVICE value_type operator* () const
 
ROCPRIM_HOST_DEVICE pointer operator-> () const
 
ROCPRIM_HOST_DEVICE constant_iteratoroperator++ ()
 
ROCPRIM_HOST_DEVICE constant_iterator operator++ (int)
 
ROCPRIM_HOST_DEVICE constant_iteratoroperator-- ()
 
ROCPRIM_HOST_DEVICE constant_iterator operator-- (int)
 
ROCPRIM_HOST_DEVICE constant_iterator operator+ (difference_type distance) const
 
ROCPRIM_HOST_DEVICE constant_iteratoroperator+= (difference_type distance)
 
ROCPRIM_HOST_DEVICE constant_iterator operator- (difference_type distance) const
 
ROCPRIM_HOST_DEVICE constant_iteratoroperator-= (difference_type distance)
 
ROCPRIM_HOST_DEVICE difference_type operator- (constant_iterator other) const
 
ROCPRIM_HOST_DEVICE value_type operator[] (difference_type) const
 Constant_iterator is not writable, so we don't return reference, just something convertible to reference. More...
 
ROCPRIM_HOST_DEVICE bool operator== (constant_iterator other) const
 
ROCPRIM_HOST_DEVICE bool operator!= (constant_iterator other) const
 
ROCPRIM_HOST_DEVICE bool operator< (constant_iterator other) const
 
ROCPRIM_HOST_DEVICE bool operator<= (constant_iterator other) const
 
ROCPRIM_HOST_DEVICE bool operator> (constant_iterator other) const
 
ROCPRIM_HOST_DEVICE bool operator>= (constant_iterator other) const
 

Friends

std::ostream & operator<< (std::ostream &os, const constant_iterator &iter)
 

Detailed Description

template<class ValueType, class Difference = std::ptrdiff_t>
class constant_iterator< ValueType, Difference >

A random-access input (read-only) iterator which generates a sequence of homogeneous values.

Overview
  • A constant_iterator represents a pointer into a range of same values.
  • Using it for simulating a range filled with a sequence of same values saves memory capacity and bandwidth.
Template Parameters
ValueType- type of value that can be obtained by dereferencing the iterator.
Difference- a type used for identify distance between iterators

Member Typedef Documentation

◆ pointer

template<class ValueType, class Difference = std::ptrdiff_t>
using constant_iterator< ValueType, Difference >::pointer = const value_type*

A pointer type of the type iterated over (value_type).

It's const since constant_iterator is a read-only iterator.

◆ reference

template<class ValueType, class Difference = std::ptrdiff_t>
using constant_iterator< ValueType, Difference >::reference = value_type

A reference type of the type iterated over (value_type).

It's same as value_type since constant_iterator is a read-only iterator and does not have underlying buffer.

Constructor & Destructor Documentation

◆ constant_iterator()

template<class ValueType, class Difference = std::ptrdiff_t>
ROCPRIM_HOST_DEVICE constant_iterator< ValueType, Difference >::constant_iterator ( const value_type  value,
const size_t  index = 0 
)
inlineexplicit

Creates constant_iterator and sets its initial value to value.

Parameters
valueinitial value
indexoptional index for constant_iterator

Member Function Documentation

◆ operator[]()

template<class ValueType, class Difference = std::ptrdiff_t>
ROCPRIM_HOST_DEVICE value_type constant_iterator< ValueType, Difference >::operator[] ( difference_type  ) const
inline

Constant_iterator is not writable, so we don't return reference, just something convertible to reference.

That matches requirement of RandomAccessIterator concept


The documentation for this class was generated from the following file: