C++26

Revision of the C++ programming language released in 2026 From Wikipedia, the free encyclopedia

C++26 is the informal name for the open standard revision of the International Organization for Standardization (ISO) and International Electrotechnical Commission (IEC) 14882 standard for the C++ programming language that follows C++23, officially shipped by WG21 on 28 March 2026.[1][2] The current working revision of C++26 is N5032.[3]

Papers proposed and adopted into the standard by the C++ Standards Committee and minutes of the standardization meeting held at Sofia, Bulgaria and online in June 2025 are publicly available.[4] The draft wording is feature complete,[5] and is being sent out for international comment ballot.[6] After resolving some ballot comments at the November 2025 standardization meeting in Kona, Hawaii, the C++ Standards Committee finished expected resolving ballot comments, technically finalized the draft, and send the draft out for final approval ballot at the following standardization meeting[5] in London, United Kingdom from 23 to 28 of March 2026.[7][8]

Experimental and standard compilers implementing some of the upcoming features can be tried on short code snippets through the Compiler Explorer. Some of the compiler variants are distinguished only by the short identifiers of papers proposing the new features they implement, such as "P3372" for constexpr containers and adaptors.

Features

Changes that have been accepted into C++26 include:

Language

  • Compile-time reflection.[9] (An experimental fork of Clang by Dan Katz, as well as GCC 16, implement these features. These compilers as well as another implementation from EDG can all be tried through the Compiler Explorer.) This uses a new operator ^^ (colloquially called the "cat-ears operator"[10]) for invoking reflection, rather than the Reflection TS keyword reflexpr.
  • Support for annotations to be used in reflection which behave differently from the existing attribute system used by the compiler.[11]
  • Contracts[12] adding keyword contract_assert, and additionally identifiers with special meaning, pre and post.[13] (An experimental fork of Clang by Eric W Fiselier and a few GCC variants supporting contracts are available through the Compiler Explorer.)
  • User-generated static_assert messages[14]
  • Introduction of erroneous behaviour for reading uninitialized variables [15]
  • [[indeterminate]] attribute, which indicates that a variable or function parameter has an indeterminate value if not initialized[16][17]
  • Deprecate std::memory_order::consume and std::kill_dependency()[18][19], due to complicating the memory model[further explanation needed] and low compiler adoption[20]
  • Remove [[carries_dependency]] attribute, due to the deprecation of std::memory_order::consume[21]
  • Deleting a pointer to an incomplete type should be ill-formed
  • Removing deprecated array comparisons
  • constexpr structured bindings and references to constexpr variables
  • constexpr placement new
  • constexpr cast from void*
  • constexpr containers and adaptors [22]
  • constexpr virtual inheritance[23]
  • constexpr exceptions[24]
  • Allowing exception throwing in constant-evaluation[24]
  • Variadic friends
  • Oxford variadic comma, i.e. "Deprecate ellipsis parameters without a preceding comma." For example, the syntax void f(int a...); is incompatible with C, detrimental to C++, and easily replaceable with void f(int a, ...);.[25]
  • Placeholder variables with no name[26]
  • Ordering of constraints involving fold expressions
  • Pack indexing
  • Structured bindings can introduce a pack
  • Attributes for structured bindings
  • Structured binding declaration as a condition
  • Adds #embed directive (first introduced in C23) for binary resource inclusion and __has_embed allowing the availability of a resource to be checked by preprocessor directives
  • Unevaluated strings
  • Adding @, $, and ` to the basic character set. While currently unused, this would allow those characters to be given potential use in the future.
  • = delete("reason");, disabling methods/functions with a specified reason
  • Forbidding returning reference to a temporary variable in a function [27]
  • template for compile-time loops (a.k.a. expansion statements)[28] to iterate over type/parameter packs, tuple-like objects and meta-objects.[29]

Library

  • New standard library headers:
    • <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 (similar to an object pool). It is based on plf::colony.
    • <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
  • Parallel scheduler (in <execution>) providing a standard async execution context that guarantees forward progress,[30] with the "execution control library" for asynchronous operations and coroutines, including a std::execution::task class[31]
  • Async sender/receiver model for structured concurrency[32] (Libunifex is a prototype implementation that can be compiled in C++17 or later.)
  • Bounds-hardened standard library[33]
  • std::copyable_function, general-purpose polymorphic function wrapper which may be copy-constructed and copy-assigned
  • std::is_within_lifetime, determines if a pointer points to an object that is within its lifetime
  • std::submdspan(), returns a view of a subset of an existing std::mdspan
  • Native handles in file streams
  • Specialization of std::formatter<> for std::filesystem::path (std::formatter<std::filesystem::path>)
  • Interfacing string streams with std::string_view
  • Interfacing std::bitset with std::string_view
  • std::views::concat, a view for concatenation of other views
  • Concatenation of strings and string views
  • Printing blank lines with std::println() (already implemented in C++23 by most compiler vendors)
  • std::ranges::generate_random, fills a range with random numbers from a uniform random bit generator
  • Hashing support for std::chrono value classes
  • Added tuple protocol to std::complex
  • More constexpr for <cmath> and <complex>
  • Adding the new 2022 SI prefixes on ratios: std::quecto, std::ronto, std::ronna, and std::quetta
  • Saturation arithmetic with, among others, std::add_sat, std::div_sat

Reception

Several people issued trip reports from the Sofia C++ Standards Committee meeting at which the draft became feature complete,[30][34] and from the International C++ Conference, C++ On Sea, immediately afterward.[35]

All highlighted the introduction of compile-time reflection in particular as a major change. In particular, Herb Sutter, chair of the ISO C++ Standards Committee and Hana Dusíková, assistant chair of the "Language Evolution" working group of the C++ Standards Committee, described the potential impacts for including reflection to C++ as a "whole new language."[30] Sutter further described C++26 as the most 'compelling' release since C++11.[2]

The contracts feature for C++26 has been criticised by some in the C++ committee, for varying reasons.[36]

The trivial relocatability feature, which proposed the new identifiers/class property specifiers trivially_relocatable_if_eligible and replaceable_if_eligible,[13] was removed from C++26 due to implementation bugs and deferred to a later standard.[37]

See also

References

Related Articles

Wikiwand AI