Lambdas finally make <algorithm> ergonomic; all_of/any_of/none_of, find_if, count_if replace hand loops that merely scan.
bool ok = std::all_of(v.begin(), v.end(),
[](const Job& j) { return j.done(); });
From <algorithm>+lambdas to composable lazy views.
Lambdas finally make <algorithm> ergonomic; all_of/any_of/none_of, find_if, count_if replace hand loops that merely scan.
bool ok = std::all_of(v.begin(), v.end(),
[](const Job& j) { return j.done(); });
Generic lambdas ([](const auto& x)) decouple call sites from element types; std::mismatch/equal get proper two-range overloads.
Parallel execution policies bolt onto the same algorithms; std::sample, clamp, reduce, transform_reduce fill gaps.
std::sort(std::execution::par_unseq, v.begin(), v.end());
auto total = std::transform_reduce(std::execution::par,
v.begin(), v.end(), 0.0,
std::plus<>{}, area);
Ranges: whole-container calls, projections, and lazy composable views with |. The raw loop survives only where it is genuinely clearer.
std::ranges::sort(people, {}, &Person::name); // projection
auto names = people
| std::views::filter(&Person::active)
| std::views::transform(&Person::name);
The gaps close: views::zip, enumerate, chunk, slide, adjacent, join_with; ranges::to<Container> materializes pipelines; fold_left family lands.
auto top = scores
| std::views::enumerate
| std::views::take(10)
| std::ranges::to<std::vector>();
views::concat joins heterogeneous ranges, and parallel range algorithms (P3179) marry the C++17 policies to the C++20 interface.
for (auto&& x : std::views::concat(header, body, footer)) emit(x);
Direction: more views, SIMD-aware algorithm execution, and tighter ranges/std::execution integration are the active pipeline.
C++26 per the final working draft; C++29 rows are proposals and direction, not adopted features.