In range-v3, is there a more efficient way (less steps, cleaner, more expressive, more elegant, more performant, ...) to create a view by selecting elements of a range by arbitrary indexes of the range than using views::counted plus views::concat as in
auto v = std::vector<int> {6,7,8,9,10,11};
auto v1 = views::counted(ranges::begin(v) + 1, 1); // [7]
auto v2 = views::counted(ranges::begin(v) + 3, 1); // [9]
auto v3 = views::counted(ranges::begin(v) + 4, 1); // [10]
auto vFinal = views::concat(v1,v2,v3); // [7,9,10]
You can wrap up the calls to
ranges::views::concat
by putting the indices in a range, and callingranges::views::for_each
which maps each element to a function returning a range, then concatenates everything.https://godbolt.org/z/Wocb8W