C++23

C++23 is the informal name for the next version of the ISO/IEC 14882 standard for the C++ programming language that will follow C++20. The final draft of this version is N4950.[1][2]

In February 2020, at the final meeting for C++20 in Prague, an overall plan for C++23 was adopted:[3][4] planned features for C++23 are library support for coroutines, a modular standard library, executors, and networking.

The first WG21 meeting focused on C++23 was intended to take place in Varna in early June 2020, but was cancelled due to the COVID-19 pandemic,[5][6] as was the November 2020 meeting in New York[7][6] and the February 2021 meeting in Kona, Hawaii.[7] All meetings until November 2022 were virtual while the November 2022 meeting was hybrid.[7]

New features

In the absence of face-to-face WG21 meetings during the COVID pandemic, few new features were added to the C++23 draft in early standards meetings. The following were added after the virtual WG21 meeting of 9 November 2020, where they were approved by straw polls:[8]

  • Literal suffixes for std::size_t and the corresponding signed type[9]
  • A member function contains for std::basic_string and std::basic_string_view, to check whether or not the string contains a given substring or character[10]
  • A stacktrace library (<stacktrace>), based on Boost.Stacktrace[11]
  • A type trait std::is_scoped_enum[12]
  • The header <stdatomic.h>, for interoperability with C atomics[13]

After the virtual WG21 meeting of 22 February 2021, following features are added where they were approved by straw polls:[14]

  • Removing unnecessary empty parameter list () from lambda expressions.[15]
  • Repairing input range adaptors and counted_iterator.[16]
  • Relax the requirements for time_point::clock.[17]
  • std::visit for classes that are derived from std::variant.[18]
  • Locks lock lockables.[19]
  • Conditionally borrowed ranges.[20]
  • std::to_underlying.[21]

After the summer 2021 ISO C++ standards plenary virtual meeting of June 2021, new features and defect reports were approved by straw polls:[22]

  • Consteval if (if consteval).[23]
  • Narrowing contextual conversions to bool.[24]
  • Allowing duplicate attributes.[25]
  • std::span-based string-stream (<spanstream>).[26]
  • std::out_ptr() and std::inout_ptr().[27]
  • constexpr for std::optional, std::variant,[28] and std::type_info::operator==.[29]
  • Iterators pair constructors for std::stack (stack) and std::queue (queue).[30]
  • Few changes of the ranges library:
    • Generalized starts_with and ends_with for arbitrary ranges.[31]
    • Renamed split_view to lazy_split_view and new split_view.[32]
    • Relaxing the constraint on join_view.[33]
    • Removing default_initializable constraint from concept view.[34]
    • Range constructor for std::basic_string_view.[35]
  • Prohibiting std::basic_string and std::basic_string_view construction from nullptr.[36]
  • std::invoke_r.[37]
  • Improvements on std::format.[38]
  • Adding default arguments for std::pair's forwarding constructor.[39]

After the autumn 2021 ISO C++ standards plenary virtual meeting of October 2021, new features and defect reports were approved by straw polls:[40]

  • Non-literal variables, labels, and gotos in constexpr functions, but still ill-formed to evaluate them at compile-time.[41]
  • Explicit this object parameter.[42]
  • Changes on character sets and encodings.[43][44]
  • New preprocessors: #elifdef and #elifndef.[45] Both directives were added to C23 (C language update) and GCC 12.[46]
  • Allowing alias declarations in init-statement.[47]
  • Overloading multidimensional subscript operator (e.g. arr[1, 2]).[48]
  • Decay copy in language: auto(x) or auto{x}.[49]
  • Changes in text formatting library:
    • Fixing locale handling in chrono formatters.[50]
    • Use of forwarding references in format arguments to allow std::generator-like types.[51]
  • Addition of type alias std::pmr::stacktrace which is equivalent to std::basic_stacktrace<std::pmr::polymorphic_allocator>.[52]
  • Changes in ranges library:
    • Refined definition of a view.[53]
    • Replacing function template std::ranges::istream_view with alias templates std::ranges::istream_view, std::ranges::wistream_view, and customization point object std::views::istream.[54]
    • zip range adaptor family:[55]
      • zip_view
      • zip_transform_view
      • adjacent_view (and std::views::pairwise being equivalent to std::views::adjacent<2>)
      • adjacent_transform_view (and std::views::pairwise_transform being equivalent to std::views::adjacent_transform<2>)
  • std::move_only_function.[56]
  • Monadic operations for std::optional.[57]
  • Member function template std::basic_string::resize_and_overwrite.[58]
  • Printing volatile pointers (volatile T*).[59]
  • std::byteswap.[60]
  • Heterogeneous erasure overloads for associative containers.[61]
  • Every specialization of std::span and std::basic_string_view is trivially copyable.[62]
  • Adding conditional noexcept specifications to std::exchange.[63]
  • Revamped specification and use of integer-class types.[64]
  • Clarify C headers. "The headers are not useful in code that is only required to be valid C++. Therefore, the C headers should be provided by the C++ standard library as a fully-supported, not deprecated part, but they should also be discouraged for use in code that is not polyglot interoperability code. [..] This proposal makes the C headers no longer deprecated, so there is no formal threat of future removal. The effective discouragement to use the C headers in pure C++ code is now spelled out explicitly as normative discouragement."[65]

After the virtual WG21 meeting of 7 February 2022, the following features are added where they were approved by straw polls:[66]

  • Allowed attributes on the function call operator of a lambda[67]
  • std::expected[68]
  • constexpr for cmath and cstdlib[69]
  • Function to mark unreachable code[70]
  • ranges::to[71]
  • A type trait to detect reference binding to temporary[72]
  • Making std::unique_ptr constexpr[73]
  • Pipe support for user-defined range adaptors[74]
  • ranges::iota, ranges::shift_left and ranges::shift_right[75]
  • views::join_with[76]
  • Windowing range adaptors: views::chunk and views::slide[77]
  • views::chunk_by[78]

After the virtual WG21 meeting of 25 July 2022, the following features and defect reports are added where they were approved by straw polls:[79]

  • Made rewriting equality in expressions less of a breaking change.[80]
  • Reverted the deprecation of bitwise assignment to volatile variables.[81]
  • Added the #warning preprocessor directive.[82]
  • Removed non-encodable wide character literals and multicharacter wide character literals.[83]
  • Allowed labels to appear at the end of compound statements.[84]
  • Added escape sequences delimited with curly braces for octal and hexadecimal numbers and universal character names.[85]
  • Allowed constexpr functions to never be constant expressions.[86]
  • Simplified some implicit move rules from C++20 and allowed implicit move when returning an rvalue reference.[87]
  • Add a way to specify unicode characters by name. For example, U'\N{LATIN CAPITAL LETTER A WITH MACRON}' // Equivalent to U'\u0100'[88]
  • Allowed operator() and lambdas to be static.[89]
  • Allowed the this pointer and references of unknown origin to appear in constant expressions.[90]
  • Allowed implementations to define extended floating-point types in addition to the three standard floating-point types. Added the type aliases std::float16_t, std::float32_t, std::float64_t, std::float128_t, std::bfloat16_t for these extended types accessible through the header <stdfloat>, their corresponding literal suffixes f16 f32 f64 f128 bf16or F16 F32 F64 F128 BF16 and added overloads to various standard library functions that take floats as arguments.[91]
  • Added the [[assume(expression)]] attribute which allows the compiler to assume the provided expression is true to allow optimizations.[92]
  • Made support for UTF-8 source files mandatory, providing a portable encoding for source files.[93]
  • Allowed arrays of char and unsigned char to be initialized with UTF-8 string literals.[94]
  • Removed the requirement that wchar_t can encode all characters of the extended character set, in effect allowing UTF-16 to be used for wide string literals.[95]
  • Added std::mdspan, a multidimensional array view analogous to std::span.[96][97][98][99]
  • flat_map and flat_set were added to the standard library.[100][101]
  • Added the std::print and std::println functions for printing formatted text to stdout.[102]
  • Provide the named modules std and std.compat for importing the standard library.[103]
  • Added support for exclusive mode fstreams, analogous to the "x" flag in fopen.[104]
  • Allowed std::format to handle Ranges.[105]
  • Made std::string::substr use move semantics.[106]
  • Added std::generator which implements a coroutine generator that models std::ranges::input_range[107]

After the hybrid WG21 meeting of 7 November 2022, the following features and defect reports are added where they were approved by straw polls:[108]

  • Allowed operator[] to be static.[109]
  • Allowed static and thread_local variables to appear in constexpr functions if they are usable in constant expressions.[110]
  • consteval propagates upwards, that is, certain existing constexpr functions become consteval functions when those functions can already only be invoked during compile time.[111]
  • Extended the lifetime of temporaries that appear in the for-range-initializer of a range-based for loop to cover the entire loop.[112]
  • Reverted the deprecation of (all, not just bitwise) compound assignment to volatile variables.[113]
  • Monadic functions for std::expected.[114]
  • Synchronize the output of std::print with the underlying stream if the native Unicode API is used.[115]

Removed and deprecated features

  • Removed the garbage collection support that was added in C++11, despite many GC implementations available for C++; "Garbage Collection in C++ is clearly useful for particular applications. However, Garbage Collection as specified by the Standard is not useful for those applications."[116]
  • Deprecate std::aligned_storage and std::aligned_union[117]

References

  1. "Working Draft, Standard for Programming Language C++" (PDF). 2023-05-10.
  2. "N4951 Editors' Report: Programming Languages - C++". 2023-05-10. Archived from the original on 2023-06-05.
  3. Dusíková, Hana (2019-11-06). "N4817: 2020 Prague Meeting Invitation and Information" (PDF). Archived (PDF) from the original on 2019-12-29. Retrieved 2020-02-13.
  4. Voutilainen, Ville (2019-11-25). "To boldly suggest an overall plan for C++23". www.open-std.org. Archived from the original on 2019-12-24. Retrieved 2020-02-13.
  5. "P2145R0: Evolving C++ Remotely". www.open-std.org.
  6. Sutter, Herb (29 July 2020). "Business Plan and Convener's Report: ISO/IEC JTC1/SC22/WG21 (C++)" (PDF).
  7. "Upcoming Meetings, Past Meetings : Standard C++". isocpp.org.
  8. Ranns, Nina (2020-11-19). "WG21 2020-11 Virtual Meeting: Minutes of Meeting" (PDF).
  9. JeanHeyd Meneide; Rein Halbersma (2019-11-24). "Literal Suffix for (signed) size_t".
  10. Wim Leflere; Paul Fee (2020-06-13). "string contains function".
  11. Alexey Gorgurov; Antony Polukhin (2020-09-16). "A Proposal to add stacktrace library".
  12. Juan Alday (2020-10-12). "A proposal for a type trait to detect scoped enumerations" (PDF).
  13. Hans-J. Boehm (2020-10-23). "P0943R6: Support C atomics in C++".
  14. Ranns, Nina (2021-02-22). "WG21 2021-02 Virtual Meeting: Minutes of Meeting" (PDF).
  15. Alex Christensen; JF Bastien (2020-12-11). "P1102R2: Down with ()!".
  16. Tim Song (2021-01-12). "Repairing input range adaptors and counted_iterator".
  17. Alexey Dmitriev; Howard Hinnant (2020-10-22). "Relax Requirements for time_point::clock".
  18. Barry Revzin (2020-10-30). "Inheriting from std::variant".
  19. Tim Song (2020-11-13). "Locks lock lockables".
  20. Barry Revzin (2020-02-19). "Conditionally borrowed ranges".
  21. JeanHeyd Meneide (2021-01-22). "std::to_underlying for enumerations".
  22. Ranns, Nina (2021-06-07). "WG21 2021-06 Virtual MeetingMinutes of Meeting" (PDF).
  23. Barry Revzin; Richard Smith; Andrew Sutton; Daveed Vandevoorde (2021-03-22). "if consteval".
  24. Andrzej Krzemieński (2021-04-12). "Narrowing contextual conversions to bool".
  25. Erich Keane (2020-07-02). "Allow Duplicate Attributes" (PDF).
  26. Peter Sommerlad (2021-02-26). "A strstream replacement using span<charT> as buffer" (PDF).
  27. JeanHeyd Meneide; Todor Buyukliev; Isabella Muerte (2021-04-15). "out_ptr - a scalable output pointer abstraction".
  28. Barry Revzin (2021-02-11). "Missing constexpr in std::optional and std::variant".
  29. Peter Dimov (2021-05-01). "Making std::type_info::operator== constexpr".
  30. Corentin Jabot (2021-03-05). "Iterators pair constructors for stack and queue" (PDF).
  31. Christopher Di Bella (2021-02-19). "starts_with and ends_with".
  32. Barry Revzin (2021-03-05). "Superior String Splitting".
  33. Tim Song (2021-05-06). "join_view should join all views of ranges".
  34. Barry Revzin (2021-05-14). "Views should not be required to be default constructible".
  35. Corentin Jabot (2021-03-17). "Range constructor forstd::string_view 2: Constrain Harder" (PDF).
  36. Yuriy Chernyshov (2020-09-06). "A Proposal to Prohibit std::basic_string and std::basic_string_view construction from nullptr".
  37. Zhihao Yuan (2020-04-29). "invoke_r".
  38. Victor Zverovich (2021-02-05). "std::format improvements".
  39. Logan R. Smith (2021-01-25). "Default Arguments for pair's Forwarding Constructor".
  40. Ranns, Nina (2021-10-04). "WG21 2021-10 Virtual Meeting Minutes of Meeting" (PDF).
  41. Ville Voutilainen (2021-07-12). "Non-literal variables (and labels and gotos) in constexpr functions".
  42. Gašper Ažman; Sy Brand; Ben Deane; Barry Revzin (2021-07-12). "Deducing this".
  43. Corentin Jabot (2021-09-14). "Consistent character literal encoding" (PDF).
  44. Jens Maurer (2021-09-21). "Character sets and encodings".
  45. Melanie Blower (2021-04-30). "Add support for preprocessing directives elifdef and elifndef" (PDF).
  46. "GCC 12 Adds Support For New #elifdef #elifndef Directives". phoronix. May 12, 2021. Archived from the original on December 27, 2022.
  47. Jens Maurer (2021-04-13). "Extend init-statement to allow alias-declaration".
  48. Mark Hoemmen; Daisy Hollman; Corentin Jabot; Isabella Muerte; Christian Trott (2021-09-14). "Multidimensional subscript operator" (PDF).
  49. Zhihao Yuan (2021-07-12). "auto(x): decay-copy in the language".
  50. Victor Zverovich; Corentin Jabot (2021-09-11). "Fixing locale handling in chrono formatters".
  51. Victor Zverovich (2021-09-24). "Add support for std::generator-like types to std::format".
  52. Steve Downey (2021-06-14). "Add a pmr alias for std::stacktrace".
  53. Barry Revzin; Tim Song (2021-08-15). "What is a view?".
  54. Nicolai Josuttis (2021-09-24). "Fix istream_view" (PDF).
  55. Tim Song (2021-06-11). "zip".
  56. Matt Calabrese; Ryan McDougall (2021-07-09). "move_only_function".
  57. Sy Brand (2021-04-27). "Monadic operations for std::optional".
  58. Chris Kennelly; Mark Zeren (2021-09-14). "basic_string::resize_and_overwrite".
  59. Bryce Adelstein Lelbach (2021-09-25). "Printing volatile Pointers".
  60. Isabella Muerte; Corentin Jabot (2021-09-17). "Byteswapping for fun&&nuf".
  61. Konstantin Boyarinov; Sergey Vinogradov; Ruslan Arutyunyan (2020-12-15). "Heterogeneous erasure overloads for associative containers".
  62. Nevin Liber (2021-03-19). "Require span & basic_string_view to be TriviallyCopyable" (PDF).
  63. Giuseppe D'Angelo (2021-06-28). "Add a conditional noexcept specification to std::exchange".
  64. Tim Song (2021-08-06). "Cleaning up integer-class types".
  65. Thomas Köppe (2021-06-11). "Clarifying the status of the "C headers"".
  66. Ranns, Nina (2022-02-07). "WG21 2022-02 Virtual Meeting: Minutes of Meeting" (PDF).
  67. "Attributes on Lambda-Expressions" (PDF).
  68. Vicente Botet; JF Bastien; Jonathan Wakely (2022-01-07). "std::expected".
  69. Edward J. Rosten; Oliver J. Rosten (2021-11-12). "constexpr for <cmath> and <cstdlib>" (PDF).
  70. Melissa Mears; Jens Maurer (2021-10-15). "Function to mark unreachable code" (PDF).
  71. Corentin Jabot; Eric Niebler; Casey Carter (2022-01-21). "Conversions from ranges to containers" (PDF).
  72. Tim Song (2021-10-13). "A type trait to detect reference binding to temporary".
  73. Andreas Fertig (2021-11-06). "Making std::unique_ptr constexpr" (PDF).
  74. Barry Revzin (2021-12-17). "Pipe support for user-defined range adaptors".
  75. Tim Song (2021-12-05). "ranges::iota, ranges::shift_left, and ranges::shift_right".
  76. Barry Revzin (2022-01-28). "views::join_with".
  77. Tim Song (2021-12-05). "Windowing range adaptors: views::chunk and views::slide".
  78. Tim Song (2021-11-19). "views::chunk_by".
  79. Ranns, Nina (2022-08-09). "WG21 2022-07 Virtual Meeting: Minutes of Meeting" (PDF).
  80. "The Equality Operator You Are Looking For". 2022-01-13.
  81. "De-deprecating volatile compound operations" (PDF).
  82. "Support for #warning" (PDF). 2022-01-13.
  83. "Remove non-encodable wide character literals and multicharacter wide character literals" (PDF).
  84. "Labels at the end of compound statements (C compatibility)" (PDF). 2022-01-13.
  85. "Delimited escape sequences" (PDF). 2022-02-25.
  86. "Relaxing some constexpr restrictions". 2022-01-27.
  87. "Simpler implicit move". 2022-03-23.
  88. "Named universal character escapes". 2022-03-25.
  89. "static operator()". 2022-04-08.
  90. "Using unknown pointers and references in constant expressions".
  91. "Extended floating-point types and standard names". 2022-04-22.
  92. "Portable assumptions" (PDF). 2022-04-22.
  93. "Support for UTF-8 as a portable source file encoding" (PDF). 2022-07-01.
  94. "char8_t Compatibility and Portability Fix". 2022-06-17.
  95. "Relax requirements on wchar_t to match existing practices" (PDF). 2022-07-15.
  96. "MDSPAN".
  97. "index_type & size_type in mdspan" (PDF).
  98. "mdspan: rename pointer and contiguous".
  99. "Add the missing empty to mdspan".
  100. "A Standard flat_map" (PDF).
  101. "A Standard flat_set" (PDF).
  102. "Formatted output".
  103. "Standard Library Modules std and std.compat" (PDF).
  104. "Support exclusive mode for fstreams".
  105. "Formatting Ranges".
  106. "std::string::substr() &&".
  107. "(std::generator: Synchronous Coroutine Generator for Ranges)" (PDF).
  108. Ranns, Nina (2022-12-05). "WG21 2022-07 Virtual Meeting: Minutes of Meeting" (PDF).
  109. "static operator[]" (PDF). 2022-11-11.
  110. "Permitting static constexpr variables in constexpr functions". 2022-11-07.
  111. "consteval needs to propagate up". 2022-11-11.
  112. "Wording for P2644R1 Fix for Range-based for Loop". 2022-11-11.
  113. "Core Language Working Group NB comment resolutions for the November, 2022 meeting : 2654. Un-deprecation of compound volatile assignments".
  114. Jeff Garland (2022-09-28). "P2505R5 Monadic Functions for std::expected".
  115. Victor Zverovich (2022-11-08). "Should the output of std::print to a terminal be synchronized with the underlying stream?".
  116. JF Bastien; Alisdair Meredith (2021-04-16). "Removing Garbage Collection Support".
  117. CJ Johnson (2021-11-22). "Deprecate std::aligned_storage and std::aligned_union" (PDF).
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.