C++23

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

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 current draft is N4910.[1]

In February 2020, at the final meeting for C++20 in Prague, an overall plan for C++23 was adopted:[2][3] 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,[4][5] as was the November 2020 meeting in New York[6][5] and the February 2021 meeting in Kona, Hawaii.[6] All meetings are currently planned virtual until November 2022.[6]

New features[edit]

In the absence of face-to-face WG21 meetings, few new features have so far been added to the C++23 draft. But the following were added after the virtual WG21 meeting of 9 November 2020, where they were approved by straw polls:[7]

  • Literal suffixes for std::size_t and the corresponding signed type[8]
  • 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[9]
  • A stacktrace library (<stacktrace>), based on Boost.Stacktrace[10]
  • A type trait std::is_scoped_enum[11]
  • The header <stdatomic.h>, for interoperability with C atomics[12]

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

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

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

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

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

  • Non-literal variables, labels, and gotos in constexpr functions, but still ill-formed to evaluate them at compile-time.[40]
  • Explicit this object parameter.[41]
  • Changes on character sets and encodings.[42][43]
  • New preprocessors: #elifdef and #elifndef.[44]
  • Allowing alias declarations in init-statement.[45]
  • Overloading multidimensional subscript operator (e.g. arr[1, 2]).[46]
  • Decay copy in language: auto(x) or auto{x}.[47]
  • Changes in text formatting library:
    • Fixing locale handling in chrono formatters.[48]
    • Use of forwarding references in format arguments to allow std::generator-like types.[49]
  • Addition of type alias std::pmr::stacktrace which is equivalent to std::basic_stacktrace<std::pmr::polymorphic_allocator>.[50]
  • Changes in ranges library:
    • Refined definition of a view.[51]
    • 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.[52]
    • zip range adaptor family:[53]
      • 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.[54]
  • Monadic operations for std::optional.[55]
  • Member function template std::basic_string::resize_and_overwrite.[56]
  • Printing volatile pointers (volatile T*).[57]
  • std::byteswap.[58]
  • Heterogeneous erasure overloads for associative containers.[59]
  • Every specialization of std::span and std::basic_string_view is trivially copyable.[60]
  • Adding conditional noexcept specifications to std::exchange.[61]
  • Revamped specification and use of integer-class types.[62]
  • 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."[63]

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

  • std::expected[65]
  • constexpr for cmath and cstdlib[66]
  • Function to mark unreachable code[67]
  • ranges::to[68]
  • Deprecate std::aligned_storage and std::aligned_union[69]
  • A type trait to detect reference binding to temporary[70]
  • Making std::unique_ptr constexpr[71]
  • Pipe support for user-defined range adaptors[72]
  • ranges::iota, ranges::shift_left and ranges::shift_right[73]
  • views::join_with[74]
  • Windowing range adaptors: views::chunk and views::slide[75]
  • views::chunk_by[76]

Removed feature[edit]

  • 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."[77]

References[edit]

  1. ^ "Working Draft, Standard for Programming Language C++" (PDF). 2022-03-17.
  2. ^ 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.
  3. ^ 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.
  4. ^ "P2145R0: Evolving C++ Remotely". www.open-std.org.
  5. ^ a b Sutter, Herb (29 July 2020). "Business Plan and Convener's Report: ISO/IEC JTC1/SC22/WG21 (C++)" (PDF).
  6. ^ a b c "Upcoming Meetings, Past Meetings : Standard C++". isocpp.org.
  7. ^ Ranns, Nina (2020-11-19). "WG21 2020-11 Virtual Meeting: Minutes of Meeting" (PDF).
  8. ^ JeanHeyd Meneide; Rein Halbersma (2019-11-24). "Literal Suffix for (signed) size_t".
  9. ^ Wim Leflere; Paul Fee (2020-06-13). "string contains function".
  10. ^ Alexey Gorgurov; Antony Polukhin (2020-09-16). "A Proposal to add stacktrace library".
  11. ^ Juan Alday (2020-10-12). "A proposal for a type trait to detect scoped enumerations" (PDF).
  12. ^ Hans-J. Boehm (2020-10-23). "P0943R6: Support C atomics in C++".
  13. ^ Ranns, Nina (2021-02-22). "WG21 2021-02 Virtual Meeting: Minutes of Meeting" (PDF).
  14. ^ Tim Song (2021-01-12). "Repairing input range adaptors and counted_iterator".
  15. ^ Alex Christensen; JF Bastien (2020-12-11). "P1102R2: Down with ()!".
  16. ^ Alexey Dmitriev; Howard Hinnant (2020-10-22). "Relax Requirements for time_point::clock".
  17. ^ Barry Revzin (2020-10-30). "Inheriting from std::variant".
  18. ^ Tim Song (2020-11-13). "Locks lock lockables".
  19. ^ Barry Revzin (2020-02-19). "Conditionally borrowed ranges".
  20. ^ JeanHeyd Meneide (2021-01-22). "std::to_underlying for enumerations".
  21. ^ Ranns, Nina (2021-06-07). "WG21 2021-06 Virtual MeetingMinutes of Meeting" (PDF).
  22. ^ Barry Revzin; Richard Smith; Andrew Sutton; Daveed Vandevoorde (2021-03-22). "if consteval".
  23. ^ Andrzej Krzemieński (2021-04-12). "Narrowing contextual conversions to bool".
  24. ^ Erich Keane (2020-07-02). "Allow Duplicate Attributes" (PDF).
  25. ^ Peter Sommerlad (2021-02-26). "A strstream replacement using span<charT> as buffer" (PDF).
  26. ^ JeanHeyd Meneide; Todor Buyukliev; Isabella Muerte (2021-04-15). "out_ptr - a scalable output pointer abstraction".
  27. ^ Barry Revzin (2021-02-11). "Missing constexpr in std::optional and std::variant".
  28. ^ Peter Dimov (2021-05-01). "Making std::type_info::operator== constexpr".
  29. ^ Corentin Jabot (2021-03-05). "Iterators pair constructors for stack and queue" (PDF).
  30. ^ Christopher Di Bella (2021-02-19). "starts_with and ends_with".
  31. ^ Barry Revzin (2021-03-05). "Superior String Splitting".
  32. ^ Tim Song (2021-05-06). "join_view should join all views of ranges".
  33. ^ Barry Revzin (2021-05-14). "Views should not be required to be default constructible".
  34. ^ Corentin Jabot (2021-03-17). "Range constructor forstd::string_view 2: Constrain Harder" (PDF).
  35. ^ Yuriy Chernyshov (2020-09-06). "A Proposal to Prohibit std::basic_string and std::basic_string_view construction from nullptr".
  36. ^ Zhihao Yuan (2020-04-29). "invoke_r".
  37. ^ Victor Zverovich (2021-02-05). "std::format improvements".
  38. ^ Logan R. Smith (2021-01-25). "Default Arguments for pair's Forwarding Constructor".
  39. ^ Ranns, Nina (2021-10-04). "WG21 2021-10 Virtual Meeting Minutes of Meeting" (PDF).
  40. ^ Ville Voutilainen (2021-07-12). "Non-literal variables (and labels and gotos) in constexpr functions".
  41. ^ Gašper Ažman; Sy Brand; Ben Deane; Barry Revzin (2021-07-12). "Deducing this".
  42. ^ Corentin Jabot (2021-09-14). "Consistent character literal encoding" (PDF).
  43. ^ Jens Maurer (2021-09-21). "Character sets and encodings".
  44. ^ Melanie Blower (2021-04-30). "Add support for preprocessing directives elifdef and elifndef" (PDF).
  45. ^ Jens Maurer (2021-04-13). "Extend init-statement to allow alias-declaration".
  46. ^ Mark Hoemmen; Daisy Hollman; Corentin Jabot; Isabella Muerte; Christian Trott (2021-09-14). "Multidimensional subscript operator" (PDF).
  47. ^ Zhihao Yuan (2021-07-12). "auto(x): decay-copy in the language".
  48. ^ Victor Zverovich; Corentin Jabot (2021-09-11). "Fixing locale handling in chrono formatters".
  49. ^ Victor Zverovich (2021-09-24). "Add support for std::generator-like types to std::format".
  50. ^ Steve Downey (2021-06-14). "Add a pmr alias for std::stacktrace".
  51. ^ Barry Revzin; Tim Song (2021-08-15). "What is a view?".
  52. ^ Nicolai Josuttis (2021-09-24). "Fix istream_view" (PDF).
  53. ^ Tim Song (2021-06-11). "zip".
  54. ^ Matt Calabrese; Ryan McDougall (2021-07-09). "move_only_function".
  55. ^ Sy Brand (2021-04-27). "Monadic operations for std::optional".
  56. ^ Chris Kennelly; Mark Zeren (2021-09-14). "basic_string::resize_and_overwrite".
  57. ^ Bryce Adelstein Lelbach (2021-09-25). "Printing volatile Pointers".
  58. ^ Isabella Muerte; Corentin Jabot (2021-09-17). "Byteswapping for fun&&nuf".
  59. ^ Konstantin Boyarinov; Sergey Vinogradov; Ruslan Arutyunyan (2020-12-15). "Heterogeneous erasure overloads for associative containers".
  60. ^ Nevin Liber (2021-03-19). "Require span & basic_string_view to be TriviallyCopyable" (PDF).
  61. ^ Giuseppe D'Angelo (2021-06-28). "Add a conditional noexcept specification to std::exchange".
  62. ^ Tim Song (2021-08-06). "Cleaning up integer-class types".
  63. ^ Thomas Köppe (2021-06-11). "Clarifying the status of the "C headers"".
  64. ^ Ranns, Nina (2022-02-07). "WG21 2022-02 Virtual Meeting: Minutes of Meeting" (PDF).
  65. ^ Vicente Botet; JF Bastien; Jonathan Wakely (2022-01-07). "std::expected".
  66. ^ Edward J. Rosten; Oliver J. Rosten (2021-11-12). "constexpr for <cmath> and <cstdlib>" (PDF).
  67. ^ Melissa Mears; Jens Maurer (2021-10-15). "Function to mark unreachable code" (PDF).
  68. ^ Corentin Jabot; Eric Niebler; Casey Carter (2022-01-21). "Conversions from ranges to containers" (PDF).
  69. ^ CJ Johnson (2021-11-22). "Deprecate std::aligned_storage and std::aligned_union" (PDF).
  70. ^ Tim Song (2021-10-13). "A type trait to detect reference binding to temporary".
  71. ^ Andreas Fertig (2021-11-06). "Making std::unique_ptr constexpr" (PDF).
  72. ^ Barry Revzin (2021-12-17). "Pipe support for user-defined range adaptors".
  73. ^ Tim Song (2021-12-05). "ranges::iota, ranges::shift_left, and ranges::shift_right".
  74. ^ Barry Revzin (2022-01-28). "views::join_with".
  75. ^ Tim Song (2021-12-05). "Windowing range adaptors: views::chunk and views::slide".
  76. ^ Tim Song (2021-11-19). "views::chunk_by".
  77. ^ JF Bastien; Alisdair Meredith (2021-04-16). "Removing Garbage Collection Support".