Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards


Class template strided_iterator

boost::compute::strided_iterator — An iterator adaptor with adjustable iteration step.


// In header: <boost/compute/iterator/strided_iterator.hpp>

template<typename Iterator> 
class strided_iterator {
  // types
  typedef unspecified                 super_type;     
  typedef super_type::value_type      value_type;     
  typedef super_type::reference       reference;      
  typedef super_type::base_type       base_type;      
  typedef super_type::difference_type difference_type;

  // construct/copy/destruct
  strided_iterator(Iterator, difference_type);
  strided_iterator(const strided_iterator< Iterator > &);
  strided_iterator< Iterator > & 
  operator=(const strided_iterator< Iterator > &);

  // public member functions
  size_t get_index() const;
  const buffer & get_buffer() const;
  template<typename IndexExpression> 
    unspecified operator[](const IndexExpression &) const;

  // private member functions
  reference dereference() const;
  bool equal(const strided_iterator< Iterator > &) const;
  void increment();
  void decrement();
  void advance(typename super_type::difference_type);
  difference_type distance_to(const strided_iterator< Iterator > &) const;


The strided iterator adaptor skips over multiple elements each time it is incremented or decremented.

See Also:

buffer_iterator, make_strided_iterator(), make_strided_iterator_end()

strided_iterator public construct/copy/destruct

  1. strided_iterator(Iterator iterator, difference_type stride);
  2. strided_iterator(const strided_iterator< Iterator > & other);
  3. strided_iterator< Iterator > & 
    operator=(const strided_iterator< Iterator > & other);
  4. ~strided_iterator();

strided_iterator public member functions

  1. size_t get_index() const;
  2. const buffer & get_buffer() const;
  3. template<typename IndexExpression> 
      unspecified operator[](const IndexExpression & expr) const;

strided_iterator private member functions

  1. reference dereference() const;
  2. bool equal(const strided_iterator< Iterator > & other) const;
  3. void increment();
  4. void decrement();
  5. void advance(typename super_type::difference_type n);
  6. difference_type distance_to(const strided_iterator< Iterator > & other) const;