ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
2025-03-15 N5008 N5001 C++26
C++26
C++26 is shaping up to be a substantial update, introducing several
highly anticipated features and language improvements.
For the language, it adds contracts, introducing language-level
support for design by contract, allowing specification of
preconditions, postconditions, and invariants for functions
and methods.
It brings static reflection capabilities, enabling compile-time
introspection of types and program structure, a major addition
for advanced metaprogramming and tooling.
It enables constexpr cast from void*, making certain generic
programming techniques possible at compile time.
User-generated static_assert messages are now allowed, improving
diagnostics in template-heavy code.
Placeholder variables with no name are permitted, simplifying
code that requires unused variables.
Pack indexing enhances template parameter pack manipulation.
Attributes can now be applied to structured bindings.
There are improved diagnostics and safety for uninitialized variable
reads.
Functions can be deleted with a custom reason string.
Variadic friends are enabled.
Constexpr placement new extends constant evaluation to placement
new expressions.
Structured binding declaration as a condition is now possible.
There are clarifications to template constraint resolution.
Deleting a pointer to an incomplete type is now ill-formed,
strengthening type safety.
Structured bindings can introduce a pack.
Exception throwing in constant-evaluation is permitted.
There is more flexibility in constant expressions involving
structured bindings and references to constexpr variables.
The Oxford variadic comma deprecates ellipsis parameters without
a preceding comma for better C compatibility.
Deprecated array comparisons are removed.
In the standard library, C++26 adds hashing for std::chrono
value classes, a std::is_within_lifetime utility, native
handles in file streams, string and bitset interoperability with
std::string_view, expanded constexpr support for <cmath> and
<complex>, and 2022 SI prefixes for ratios such as std::quecto,
std::ronto, std::ronna, and std::quetta.
It introduces std::copyable_function, a more flexible function
wrapper, and std::submdspan() for enhanced multidimensional
span operations.
There is a new <debugging> header for standard debugging support and
a <linalg> header introducing a BLAS-like linear algebra interface.
The tuple protocol is extended to std::complex.
The ranges library gains views::concat for concatenating ranges,
string and string view concatenation, std::ranges::generate_random
for random number generation over ranges, and the ability
to print blank lines with std::println().
There is a std::formatter for std::filesystem::path and
saturation arithmetic functions like std::add_sat and
std::div_sat for safe arithmetic.
Other notable changes include the removal of deprecated
atomic initialization APIs such as atomic_init and
ATOMIC_VAR_INIT, standardization of BLAS-like operations and
SIMD parallelism, and various proposals to improve safety,
including those championed by Bjarne Stroustrup.
Some features are still under discussion or not yet finalized,
such as further expansion of reflection, continued work
on concepts lite for template constraints, and further
integration of the Ranges v3 library.
C++23
C++23 is a moderate update compared to C++20, focusing on incremental
improvements to both the core language and the standard library.
In the core language, it introduces explicit object parameters
(deducing this), if consteval for compile-time branching,
multidimensional subscript operators, built-in decay copy
support, marking unreachable code, platform-independent
assumptions, and named universal character escapes.
In the standard library, it brings string formatting
improvements including formatting entire ranges, standard named
modules (std and std.compat), new containers like flat_map and
flat_set, multidimensional span (mdspan), a standard generator
coroutine, monadic operations on std::optional, runtime
stacktrace support, many improvements to the ranges library,
and std::expected as an alternative to exceptions.
--- MBSE BBS v1.1.1 (Linux-x86_64)
* Origin: Stefan Ram (3:633/280.2@fidonet)