Share to: share facebook share twitter share wa share telegram print page

C++26

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 N5014.[1] 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.[2] The draft wording is feature complete,[3] and is being sent out for international comment ballot.[4] After resolving some ballot comments at the November 2025 standardization meeting in Kona, Hawaii, the C++ Standards Committee is expected to finish resolving ballot comments, technically finalize the draft, and send the draft out for final approval ballot at the following standardization meeting[3] in London in March 2026.[5] 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. (An experimental fork of Clang by Dan Katz is currently the only open source compiler implementing these features. Both this fork and another implementation from EDG can be tried through the Compiler Explorer.)
  • Contracts[6] adding keyword contract_assert, and additionally identifiers with special meaning, pre and post.[7] (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[8]
  • Erroneous behavior for uninitialized reads
  • 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
  • Variadic friends
  • Allowing exception throwing in constant-evaluation
  • Placeholder variables with no name
  • Ordering of constraints involving fold expressions
  • Pack indexing
  • Structured bindings can introduce a pack
  • Attributes for structured bindings
  • Structured binding declaration as a condition
  • New identifiers/class property specifiers trivially_relocatable_if_eligible and replaceable_if_eligible[9]
  • 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
  • = delete("reason");
  • 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, ...)."[10]

Library

  • <meta>: Compile-time reflection support
  • Support for annotations to be used in reflection which behave differently from the existing attribute system used by the compiler
  • <contracts>: Design-by-contract support
  • Bounds-hardened standard library[11]
  • Parallel scheduler providing a standard async execution context that guarantees forward progress[12]
  • <simd>: Data-parallel access (Single instruction, multiple data or SIMD) support
  • Async sender/receiver model for structured concurrency[13] (Libunifex is a prototype implementation that can be compiled in C++17 or later.)
  • <hazard_pointer>: Hazard pointers for threading
  • std::copyable_function
  • std::is_within_lifetime
  • <hive>: Hive data structure support which reuses erased elements' memory
  • <rcu>: Support for safe reclamation read-copy-update mechanism
  • <inplace_vector>: In-place vector data structure support, which is a resizable, fixed capacity, inplace contiguous array
  • std::submdspan()
  • Native handles in file streams
  • std::formatter<std::filesystem::path>
  • Interfacing string streams with std::string_view
  • Interfacing std::bitset with std::string_view
  • views::concat
  • Concatenation of strings and string views
  • <text_encoding>: Support for accessing the IANA Character Sets registry
  • Printing blank lines with std::println()
  • std::ranges::generate_random
  • <linalg>: A free function linear algebra interface based on the BLAS
  • 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
  • <debugging>: Debugging support and language features to aid debugger programs

Reception

Several people issued trip reports from the Sofia C++ Standards Committee meeting at which the draft became feature complete,[12][14] and from the International C++ Conference, C++ On Sea, immediately afterward.[15] All highlighted the introduction of compile-time reflection in particular as a major change. Herb Sutter quoted Hana Dusíková, assistant chair of the "Language Evolution" working group of the C++ Standards Committee, summarizing the change's potential impact as a "whole new language."[12]

References

  1. ^ "Working Draft, Standard for Programming Language C++" (PDF). Open Standards. ISO/IEC. 2025-08-05.
  2. ^ "mailing2025-07 post-Sofia". JTC1/SC22/WG21 - The C++ Standards Committee - ISOCPP. Retrieved 6 September 2025.
  3. ^ a b "C++ IS Schedule" (PDF). JTC1/SC22/WG21 - The C++ Standards Committee - ISOCPP. Retrieved 6 September 2025.
  4. ^ "The life of an ISO proposal: from "cool idea" to "international standard"". News, Status & Discussion about Standard C++. Standard C++ Foundation. Retrieved 6 September 2025.
  5. ^ "Upcoming Meetings, Past Meetings". News, Status & Discussion about Standard C++. The Standard C++ Foundation. Retrieved 6 September 2025.
  6. ^ "Contract assertions (since C++26) - cppreference.com". en.cppreference.com. Retrieved 2025-03-09.
  7. ^ "C++ keywords - cppreference.com". en.cppreference.com. Retrieved 2025-07-27.
  8. ^ Dargo, Sandor. "C++26: user-generated static_assert messages". News, Status & Discussion about Standard C++. The Standard C++ Foundation. Retrieved 6 September 2025.
  9. ^ "C++ keywords - cppreference.com". en.cppreference.com. Retrieved 2025-07-27.
  10. ^ "P3176R1: The Oxford variadic comma". eisenwave.github.io. Retrieved 2024-12-09.
  11. ^ Sutter, Herb. "Crate-training Tiamat, un-calling Cthulhu:Taming the UB monsters in C++". Sutter's Mill.
  12. ^ a b c Sutter, Herb. "Trip report: June 2025 ISO C++ standards meeting (Sofia, Bulgaria)". Sutter's Mill. Retrieved 6 September 2025.
  13. ^ Sutter, Herb. "Trip report: Summer ISO C++ standards meeting (St Louis, MO, USA)". Sutter's Mill. Retrieved 6 September 2025.
  14. ^ Lopez-Gomez, Javier. "Summer WG21 Meeting; trip report". Javier Lopez-Gomez personal site. Retrieved 6 September 2025.
  15. ^ Dargo, Sandor. "Trip report: C++ On Sea 2025". Sandor Dargo's Blog. Retrieved 6 September 2025.
Kembali kehalaman sebelumnya