C++ 23 · Containers and algorithms

Chain lazy views

Filter and transform without creating intermediate containers (C++20).

auto squares = v | std::views::filter([](int n) { return n % 2 == 1; })
                | std::views::transform([](int n) { return n * n; });
for (int n : squares) std::cout << n << ' ';

Official C++ 23 documentation

More containers and algorithms commands

All containers and algorithms commands · C++ 23 cheatsheet

Was this page helpful?