I'm dealing with the last big 4 of C++ 20, attempting to learn the new main features. Trying some code from the web related to ranges, I've written:
std::vector ints{ 6, 5, 2, 8 };
auto even = [](int i) {
return 0 == i % 2;
};
// ranges...
auto rr = ints | std::views::filter(even)
| std::views::transform([](auto i) {
return i * i;
})
| std::views::reverse;
Then I would sort, like range-v3 does with |action::sort
, but I've understand that this implementation is not the same.
The way I've found to sort is:
ints = std::vector(std::ranges::begin(rr), std::ranges::end(rr));
std::ranges::sort(ints);
Am I wrong? Does anybody know how to sort with pipe style the view ?