22#ifndef _ITERTOOLS_SLICE_HPP
23#define _ITERTOOLS_SLICE_HPP
42 template <
typename R>
struct sliced {
65 [[nodiscard]] std::ptrdiff_t
size()
const {
66 std::ptrdiff_t total_size =
distance(std::cbegin(
rg), std::cend(
rg));
137 template <
typename R> [[nodiscard]]
sliced<R> slice(R &&rg, std::ptrdiff_t start_idx, std::ptrdiff_t end_idx) {
138 return {std::forward<R>(rg), start_idx, std::max(start_idx, end_idx)};
sliced< R > slice(R &&rg, std::ptrdiff_t start_idx, std::ptrdiff_t end_idx)
Lazy-slice a given range.
std::iterator_traits< Iter1 >::difference_type distance(Iter1 first, Iter2 last)
Calculate the distance between two iterators.
Provides some utility functions for itertools.