How C++20 Ranges allow functional, lazy stream processing without temporary vector allocations:
#include <ranges>
#include <vector>
#include <iostream>
std::vector<int> numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
auto results = numbers
| std::views::filter([](int n) { return n % 2 == 0; })
| std::views::transform([](int n) { return n * n; })
| std::views::take(3);
for (int v : results) {
std::cout << v << " "; // Prints: 4 16 36
}std::views are 100% lazy: no intermediate vectors are allocated, and elements are computed on-demand during loop iteration!