C++20

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

C++20 is the informal name for the revision of the ISO/IEC standard for the C++ programming language expected to follow C++17.[1] The C++ Standards Committee began planning C++20 in July 2017.[2] The current draft is N4810.[3]

Below is a partial list of changes that have been accepted into or have been discussed for inclusion into C++20.[4]

New features[edit]

Features voted into the C++20 draft in July 2017 (Toronto) include:[5]

  • concepts[6]
  • designated initializers[7] (based on the C99 feature)
  • [=, this] as a lambda capture[8]
  • template parameter lists on lambdas[9]

Features voted into C++20 in the fall meeting in November 2017 (Albuquerque) include:[10][11]

  • three-way comparison using the "spaceship operator", operator <=>
  • initialization of an additional variable within a range-based for statement
  • lambdas in unevaluated contexts[12][13]
  • default constructible and assignable stateless lambdas[12][14]
  • allow pack expansions in lambda init-capture[12][15]
  • string literals as template parameters[12][16]
  • atomic smart pointers (such as std::atomic<shared_ptr<T>> and std::atomic<weak_ptr<T>>)[17]

Features voted into C++20 in March 2018 (Jacksonville) include:[18]

  • removing the need for typename in certain circumstances[19]
  • new standard attributes [[likely]] and [[unlikely]][20]
  • calendar and time-zone additions to <chrono>[21]
  • std::span, providing a view of a contiguous array (analogous to std::string_view)[22]
  • <version> header[23]

Features voted into C++20 in the summer meeting in June 2018 (Rapperswil) include:[24]

  • contracts[25]
  • feature test macros[26]
  • bit-casting of object representations, with less verbosity than memcpy() and more ability to exploit compiler internals[27]
  • conditional explicit, allowing the explicit modifier to be contingent on a boolean expression[28]
  • constexpr virtual functions[29]

Features voted into C++20 in the fall meeting in November 2018 (San Diego) include:

  • ranges (The One Ranges Proposal)[30]
  • concept terse syntax[31]
  • constexpr union,[32] try and catch[33] dynamic_cast and typeid,[34] std::pointer_traits[35]
  • various constexpr library bits[36]
  • immediate functions using the new consteval keyword[37]
  • signed integers are now defined to be represented using two's complement (signed integer overflow remains undefined behavior)[38]
  • refinements of the contracts facility (access control in contract conditions)[39]
  • a revised memory model[40]

Features voted into C++20 in the winter meeting in February 2019 (Kona) include:[41] [42]

  • coroutines[43] – already experimentally supported in Clang 5[44]
  • modules[45] – experimentally supported in Clang 5[46] and Visual Studio 2015 Update 1[47] as well as GCC[48]
  • various improvements to structured bindings (interaction with lambda captures, static and thread_local storage duration)[49] [50]

Possible new features[edit]

Possible library changes[edit]

  • extended futures[52]
  • latches and barriers[53]
  • task blocks[54]
  • text formatting[55]

Features deferred to a later standard[edit]

  • Reflection[56][57]
  • Metaclasses[58]
  • Executors[59]
  • Networking extensions,[60][61] including async, basic I/O services, timers, buffers and buffer-oriented streams, sockets, and Internet protocols (blocked by executors)
  • Properties[62]

See also[edit]

References[edit]

  1. ^ "The next standard after C++17 will be C++20"., by Herb Sutter
  2. ^ "Current Status : Standard C++".
  3. ^ "Working Draft, Standard for Programming Language C++" (PDF).
  4. ^ "P0592R0: To boldly suggest an overall plan for C++20".
  5. ^ Herb Sutter. "Trip report: Summer ISO C++ standards meeting (Toronto)".
  6. ^ "P0606R0: Concepts Are Ready" (PDF).
  7. ^ Tim Shen; Richard Smith. "Designated Initialization Wording".
  8. ^ Thomas Köppe. "Allow lambda capture [=, this]".
  9. ^ "Familiar template syntax for generic lambdas".
  10. ^ Herb Sutter. "Trip report: Fall ISO C++ standards meeting (Albuquerque)".
  11. ^ Smith, Richard; Perchik, Dawn; Köppe, Thomas. "N4714 Editors' Report -- Programming Languages -- C++". C++ standards drafts. GitHub. Retrieved 27 December 2018.
  12. ^ a b c d "Trip Report: C++ Standards Meeting in Albuquerque, November 2017". There's Waldo!. 2017-11-20. Retrieved 2017-12-11.
  13. ^ "Wording for lambdas in unevaluated contexts" (PDF).
  14. ^ "Default constructible and assignable stateless lambdas" (PDF).
  15. ^ "Pack expansion in lambda init-capture". www.open-std.org. Retrieved 2017-12-11.
  16. ^ "String literals as non-type template parameters" (PDF).
  17. ^ Meredith, Alisdair; Sutter, Herb. "Revising atomic_shared_ptr for C++20". JTC1/SC22/WG21 - The C++ Standards Committee - ISOCPP. ISO. Retrieved 27 December 2018.
  18. ^ Botond Ballo. "Trip Report: C++ Standards Meeting in Jacksonville, March 2018".
  19. ^ Nina Ranns; Daveed Vandevoorde. "Down with typename!".
  20. ^ "Proposed wording for likely and unlikely attributes (Revision 5)".
  21. ^ Howard E. Hinnant; Tomasz Kamiński. "Extending <chrono> to Calendars and Time Zones".
  22. ^ Neil MacIntosh; Stephan T. Lavavej. "span: bounds-safe views for sequences of objects".
  23. ^ Alan Talbot. "<version>".
  24. ^ Herb Sutter. "Trip report: Summer ISO C++ standards meeting (Rapperswil)".
  25. ^ "Support for contract based programming in C++". www.open-std.org. Retrieved 2018-11-10.
  26. ^ "Integrating feature-test macros into the C++ WD". www.open-std.org. Retrieved 2018-11-10.
  27. ^ "Bit-casting object representations". www.open-std.org. Retrieved 2018-11-10.
  28. ^ "explicit(bool)". www.open-std.org. Retrieved 2018-11-13.
  29. ^ "Allowing Virtual Function Calls in Constant Expressions". www.open-std.org. Retrieved 2019-03-11.
  30. ^ "P0896R3" (PDF).
  31. ^ "P1141R1 - Yet another approach for constrained declarations".
  32. ^ "P1330R0 - Changing the active member of a union inside constexpr" (PDF).
  33. ^ "P1002R0 - Try-catch blocks in constexpr functions" (PDF).
  34. ^ "P1327R0 - Allowing dynamic_cast, polymorphic typeid in Constant Expressions".
  35. ^ "P1006R1 - Constexpr in std::pointer_traits" (PDF).
  36. ^ "P1032R1 - Misc constexpr bits".
  37. ^ "P1073R2 - Immediate functions".
  38. ^ "P1236R0: Alternative Wording for P0907R4 Signed Integers are Two's Complement".
  39. ^ "P1289R0 - Access control in contract conditions" (PDF).
  40. ^ "P0668R4: Revising the C++ memory model".
  41. ^ "r/cpp - 2019-02 Kona ISO C++ Committee Trip Report (C++20 design is complete; Modules in C++20; Coroutines in C++20; Reflection TS v1 published; work begins on a C++ Ecosystem Technical Report)". reddit. Retrieved 2019-02-24.
  42. ^ "Trip report: Winter ISO C++ standards meeting (Kona)". Sutter’s Mill. 2019-02-23. Retrieved 2019-02-24.
  43. ^ "N4649: Working Draft, Technical Specification on C++ Extensions for Coroutines" (PDF).
  44. ^ "Clang 5 Release Notes on coroutines".
  45. ^ "N4720: Working Draft, Extensions to C++ for Modules" (PDF).
  46. ^ "Clang 5 documentation on Modules".
  47. ^ "C++ Modules in VS 2015 Update 1".
  48. ^ "cxx-modules - GCC Wiki". gcc.gnu.org. Retrieved 2019-02-24.
  49. ^ "P1091R1: Extending structured bindings to be more like variable declarations". www.open-std.org. Retrieved 2019-02-24.
  50. ^ "P1091R2: Extending structured bindings to be more like variable declarations". www.open-std.org. Retrieved 2019-02-24.
  51. ^ "N3341: Transactional Language Constructs for C++" (PDF).
  52. ^ "Functional in C++17 and C++20".
  53. ^ "P0342R0: Timing barriers".
  54. ^ "Task Blocks".
  55. ^ "Text Formatting".
  56. ^ "Reflections on the reflection proposals - Meeting C++". meetingcpp.com. Retrieved 2017-06-30.
  57. ^ "Static reflection". www.open-std.org. Retrieved 2018-11-10.
  58. ^ Herb Sutter. "Metaclasses" (PDF).
  59. ^ "A Unified Executors Proposal for C++". www.open-std.org. Retrieved 2019-02-24.
  60. ^ "N4771: Working Draft, C++ Extensions for Networking" (PDF).
  61. ^ "ISO/IEC TS 19216:2018 Programming Languages -- C++ Extensions for Networking".
  62. ^ "A General Property Customization Mechanism". www.open-std.org. Retrieved 2019-02-24.

External links[edit]

  • JTC1/SC22/WG21 – the ISO/IEC C++ Standard Working Group (a.k.a. the C++ Standards Committee)
  • Ranges (range-v3) github repository, by Eric Niebler