Daily bit(e) of C++ | std::views::slide
Daily bit(e) of C++ ♻️94, The "sliding window" view over a range: std::views::slide.
The C++23 std::views::slide is a view over all positions of a sliding window of the specified size over the wrapped range.
I.e. the i-th element of std::views::slide of size n will be the subrange of [i, i+n) elements from the source range.
Note that iterating over the sliding windows produced by std::views::slide will inherently be O(m*n), so consider whether your use case can be implemented element-wise in O(m).