C++26
| C++ language revisions |
|---|
C++26 is the informal name for the version of the International Organization for Standardization (ISO) and International Electrotechnical Commission (IEC) 14882 standard for the C++ programming language that follows C++23. The current working draft of this version is N5008.[1]
Features
Changes that have been accepted into C++26 include:
Language
- Compile-time reflection.
- Unevaluated strings.
- Adding
@,$, and`to the basic character set. constexprcast fromvoid*.- User-generated
static_assertmessages. - Placeholder variables with no name.
- Pack indexing.
- Attributes for structured bindings.
- Erroneous behavior for uninitialized reads.
= delete("reason");- Variadic friends.
constexprplacementnew.- Structured binding declaration as a condition.
- Ordering of constraints involving fold expressions.
- Deleting a pointer to an incomplete type should be ill-formed.
- Structured bindings can introduce a pack.
- Allowing exception throwing in constant-evaluation.
constexprstructured bindings and references toconstexprvariables.- Oxford variadic comma, i.e. "Deprecate ellipsis parameters without a preceding comma. The syntax
(int...)is incompatible with C, detrimental to C++, and easily replaceable with(int, ...)."[2] - Removing deprecated array comparisons.
- Contracts[3] (no compiler is yet supporting, or keywords for) adding keyword
contract_assert, and additionally there are identifiers with special meaning,preandpost.[4] - New identifiers/class property specifiers
trivially_relocatable_if_eligibleandreplaceable_if_eligible.[5] - Adds
#embeddirective (first introduced in C23) for binary resource inclusion and__has_embedallowing the availability of a resource to be checked by preprocessor directives.
Library
- Hashing support for
std::chronovalue classes std::is_within_lifetime- Native handles in file streams
- Interfacing string streams with
std::string_view - Interfacing
std::bitsetwithstd::string_view - More
constexprfor<cmath>and<complex> - Adding the new 2022 SI prefixes on ratios:
std::quecto,std::ronto,std::ronna, andstd::quetta std::copyable_functionstd::submdspan()<contracts>: Design-by-contract support<debugging>: Debugging support and language features to aid debugger programs<hazard_pointer>: Hazard pointers for threading<hive>: Hive data structure support which reuses erased elements' memory<inplace_vector>: In-place vector data structure support, which is a resizable, fixed capacity, inplace contiguous array<linalg>: A free function linear algebra interface based on the BLAS<meta>: Compile-time reflection support<rcu>: Support for safe reclamation read-copy-update mechanism<simd>: Data-parallel access (Single instruction, multiple data or SIMD) support<text_encoding>: Support for accessing the IANA Character Sets registry- Support for annotations to be used in reflection which behave differently from the existing attribute system used by the compiler
- Added tuple protocol to
std::complex views::concat- Concatenation of strings and string views
std::ranges::generate_random- Printing blank lines with
std::println() std::formatter<std::filesystem::path>- Saturation arithmetic with, among others,
std::add_sat,std::div_sat
References
- ^ "Working Draft, Standard for Programming Language C++" (PDF). Open Standards. ISO/IEC. 2025-03-15.
- ^ "P3176R1: The Oxford variadic comma". eisenwave.github.io. Retrieved 2024-12-09.
- ^ "Contract assertions (since C++26) - cppreference.com". en.cppreference.com. Retrieved 2025-03-09.
- ^ "C++ keywords - cppreference.com". en.cppreference.com. Retrieved 2025-07-27.
- ^ "C++ keywords - cppreference.com". en.cppreference.com. Retrieved 2025-07-27.