Modern Language Features (C++17/20/23)¶
Beyond the standard library updates, the C++ language itself has evolved to become more expressive and safe.
Structured Binding (C++17)¶
Structured binding allows you to unpack tuples, pairs, structs, and arrays into individual variables.
Modules (C++20)¶
Modules promise faster build times and better isolation by replacing the textual inclusion of header files (#include).
Basic Module Interface¶
import std; (C++23)¶
C++23 standardizes the std module, allowing you to import the entire standard library at once with minimal compile-time cost.
Coroutines (C++20)¶
Coroutines allow functions to be suspended and resumed, forming the foundation for async programming and generators.
co_await: Suspend execution until a task is done.co_yield: Return a value and suspend (generator).co_return: Finish the coroutine.
Three-way Comparison (<=>) (C++20)¶
Also known as the "Spaceship Operator". It automatically generates ==, !=, <, <=, >, >=.
if consteval (C++23)¶
A safer version of if (std::is_constant_evaluated()). It executes the block only during compile-time evaluation.
Text Formatting¶
std::format (C++20)¶
A type-safe alternative to printf.
std::print (C++23)¶
Prints formatted text directly to stdout.