| Home | Libraries | People | FAQ | More

## Function template make_strided_iterator_end

boost::compute::make_strided_iterator_end

## Synopsis

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

    template<typename Iterator>
      strided_iterator< Iterator >
      make_strided_iterator_end(Iterator first, Iterator last,
                                typename std::iterator_traits< Iterator >::difference_type stride);

## Description

Returns a `strided_iterator` which refers to element that would follow the last element accessible through `strided_iterator` for `first` iterator with `stride`.

Parameter `stride` must be greater than zero.

It can be helpful when iterating over `strided_iterator`:

    // vec.size() may not be divisible by 3
    auto strided_iterator_begin = make_strided_iterator(vec.begin(), 3);
    auto strided_iterator_end = make_strided_iterator_end(vec.begin(), vec.end(), 3);

    // copy every 3rd element to result
    boost::compute::copy(
            strided_iterator_begin,
            strided_iterator_end,
            result.begin(),
            queue
    );

Parameters:

`first` | the iterator referring to the first element accessible through `strided_iterator` for `first` with `stride`
`last` | the iterator referring to the last element that may be accessible through `strided_iterator` for `first` with `stride`
`stride` | the iteration step

Returns: | a `strided_iterator` referring to element that would follow the last element accessible through strided_iterator for `first` iterator with `stride`.