Daily bit(e) of C++ | std::view::chunk
Daily bit(e) of C++ ♻️108, The C++23 view producing a range of "chunks", i.e. sub-ranges with the specified number of elements each: std::views::chunk.
The C++23 std::views::chunk produces a view of sub-ranges spanning the provided number of elements each.
If the source range cannot be divided without a remainder, the last element in the range will be a shorter subrange that contains the remainder of the elements.
The view works for input ranges and will provide additional features based on the type of the underlying range (e.g. operator[] is provided if the underlying range is random access).