Something went wrong. Try again.
A Tour of C++ for experienced programmers, as if C++26 is the only version that ever existed.
Something went wrong. Try again.
123456789101112#include <algorithm>#include <iostream>#include <vector>#include <ranges>
int main() { std::vector<int> data{1,2,3,4,5,6}; auto evens = data | std::views::filter([](int x){ return x % 2 == 0; }); auto count = std::ranges::count_if(evens, [](int){ return true; }); // count elements in view std::cout << "evens = " << count << '\n';}