Ranges, format & C++23 in C++
From the C++ cheat sheet · Modern C++ (C++20/23) · verified Jul 2026
Ranges, format & C++23
Pipelines, formatting, and the newest additions.
cpp
// Quick Reference
#include <ranges>
auto evens = v | std::views::filter([](int x){ return x%2==0; })
| std::views::transform([](int x){ return x*x; });💡 Ranges views are lazy and composable with | - nothing runs until you iterate.
⚡ std::expected<T, E> (C++23) returns a value or an error without throwing exceptions.
📌 The spaceship operator <=> = default generates all six comparison operators at once.
🟢 std::print (C++23) needs a recent compiler/libstdc++; std::format works more broadly.
rangescpp23format