Overview of C++20 Language and Library Features
masterC++20 introduces significant enhancements to both the language syntax and the standard library.
Language Features
- Coroutines: Support for asynchronous programming patterns.
- Concepts: Constraints for template arguments to improve error messages and interface design.
- Three-way comparison: The spaceship operator (
<=>). - Designated initializers: Explicitly naming members during struct initialization.
- Template syntax for lambdas: Allowing template parameters in lambda expressions.
- Range-based for loop with initializer: Adding a scope-limited variable within the loop header.
- [[likely]] and [[unlikely]] attributes: Providing hints to the compiler for branch prediction.
- Deprecate implicit capture of
this: Improving safety in lambda captures. - Class types in non-type template parameters: Allowing more complex types as template arguments.
- constexpr virtual functions: Enabling virtual functions to be evaluated at compile time.
- explicit(bool): Controlling implicit conversions for boolean types.
- Immediate functions: Using
constevalfor compile-time execution. - using enum: Bringing enum members into the surrounding scope.
- lambda capture of parameter pack: Capturing variadic template packs in lambdas.
- char8_t: A distinct type for UTF-8 characters.
- constinit: Ensuring variables are initialized at compile time.
- VA_OPT: Handling empty arguments in variadic macros.