22#ifndef _ITERTOOLS_STRIDE_HPP
23#define _ITERTOOLS_STRIDE_HPP
46 template <
typename Iter>
struct stride_iter : iterator_facade<stride_iter<Iter>, typename std::iterator_traits<Iter>::value_type> {
63 if (
stride <= 0)
throw std::runtime_error(
"The itertools::strided range requires a positive stride");
110 [[nodiscard]] std::ptrdiff_t end_offset()
const {
112 return (size == 0) ? 0 : ((size - 1) /
stride + 1) *
stride;
strided< R > stride(R &&rg, std::ptrdiff_t stride)
Lazy-stride through a given range.
std::iterator_traits< Iter1 >::difference_type distance(Iter1 first, Iter2 last)
Calculate the distance between two iterators.
Provides a CRTP base class for various iterator types in itertools.
Provides some utility functions for itertools.