#include <range/v3/all.hpp>
#include <iostream>
int main() {
std::vector<int> const v{1,2,2,3,1,2,0,4,5,2};
using namespace ranges;
auto rng = v | views::group_by([](int i, int j) { return i <= j; });
std::cout << rng << '\n';
}
The output is
[[1,2,2,3,1,2],[0,4,5,2]]
I would have expected that the less or equal function is applied to neighboring elements and that the output should be ranges of increasing elements:
In this small example:
The output is
[[1,2,2,3,1,2],[0,4,5,2]]
I would have expected that the less or equal function is applied to neighboring elements and that the output should be ranges of increasing elements:
[[1,2,2,3],[1,2],[0,4,5],[2]]
What is the expected behavior of
group_by
method?Godbolt link: https://godbolt.org/z/747KPdEr7