ericniebler / range-v3

Range library for C++14/17/20, basis for C++20's std::ranges
Other
4.06k stars 437 forks source link

chunk, but forcing stride? #1744

Closed ghost closed 1 year ago

ghost commented 1 year ago

Hi,

auto vector<int> container {0,1,2,3,4};
auto a = container | ::ranges::views::cycle | ::ranges::views::chunk(2);

gives [0,1], [2,3] and so on.

I need [0,1], [1,2], [2,3] and so on.

What is the cleanest way to do that? Thanks,

JohelEGP commented 1 year ago

https://eel.is/c++draft/range.slide#overview-example-1

I think this kind if question is better fit for https://github.com/ericniebler/range-v3/discussions or SO.

ghost commented 1 year ago

@JohelEGP thanks, and you are right about the section. That's a misfit.