Modern C++ Features
What each standard added, and the major C++20/23 features. Lambdas also have their own page earlier in this subject.
This is an overview — pick a sub-topic below.
Sub-topics (10)
C++11
`auto`, range-for, lambdas, move semantics, smart pointers, `nullptr`, `constexpr`, threads, `enum class`, `override`/`final`, variadic templates.
C++14
Generic lambdas, `make_unique`, relaxed constexpr, return type deduction, binary literals, digit separators.
C++17
Structured bindings, `if constexpr`, `optional`/`variant`/`any`, `string_view`, filesystem, fold expressions, inline variables, guaranteed copy elision.
C++20
The second big revolution: concepts, ranges, coroutines, modules, `<=>`, `format`, `span`, designated initialisers, `consteval`.
C++23
`std::expected`, `std::print`, `std::mdspan`, deducing `this`, `std::generator`, `import std;`, `std::flat_map`.
Modules
Replace header inclusion with compiled module interfaces (C++20) — faster builds, no macro leakage.
Three-Way Comparison
The spaceship operator `<=>` generates all comparisons at once (C++20).
Designated Initializers
Initialise aggregate members by name (C++20).
Generic Lambdas
Lambdas with `auto` parameters work for any type (C++14); C++20 adds template parameter lists.
Contracts
Preconditions, postconditions and assertions as part of function declarations (C++26).
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.