Untitled
unknown
c_cpp
2 years ago
617 B
3
Indexable
Never
#include <vector> #include <ranges> #include <iostream> template <std::ranges::range R> auto fussyChooser(R&& range) { auto odd = [](auto a) { return a % 2 != 0; }; auto div2 = [](int n) { return n / 2.0; }; return range | std::ranges::views::filter(odd) | std::ranges::views::drop(3) | std::ranges::views::transform(div2); } template <std::ranges::range R> void prntOut(R&& a) { for (auto x : a) { std::cout << x << std::endl; } } int main() { std::vector<int> vect = { 1,7,63,34,4,3,2,5,6,8,12,7,13,15 }; prntOut(fussyChooser(vect)); }