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 N4778.[3]

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

Possible new language features[edit]

The following were voted into the C++20 draft in July 2017:[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 include:[10]

  • three-way comparison using the "spaceship operator", operator <=>
  • initialization of an additional variable within a range-based for statement
  • lambdas in unevaluated contexts[11][12]
  • default constructible and assignable stateless lambdas[11][13]
  • allow pack expansions in lambda init-capture[11][14]
  • string literals as template parameters[11][15]


Features voted into C++20 in the summer meeting in June 2018 include:[16]

  • contracts[17]
  • feature test macros[18]
  • bit-casting of object representations, with less verbosity than memcpy() and more ability to exploit compiler internals[19]
  • conditional explicit, allowing the explicit modifier to be contingent on a boolean expression[20]


Features voted into C++20 in the fall meeting in November 2018 include:

  • ranges (The One Ranges Proposal)[21]
  • concept terse syntax[22]
  • constexpr union,[23] try and catch[24] dynamic_cast and typeid,[25] std::pointer_traits[26]
  • various constexpr library bits[27]
  • immediate functions using the new consteval keyword[28]
  • signed integers are now defined to be represented using two's complement[29]
  • refinements of the contracts facility (access control in contract conditions)[30]
  • a revised memory model[31]


Other possible new language features:


Features deferred to a later standard:

Possible library changes[edit]

  • atomic smart pointers[41] (std::atomic_shared_ptr and std::atomic_weak_ptr)
  • extended futures[42]
  • latches and barriers[43]
  • networking extensions,[44] including async, basic I/O services, timers, buffers and buffer-oriented streams, sockets, and Internet protocols
  • ranges[45]
  • task blocks[46]
  • text formatting[47]

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. ^ a b c d "Trip Report: C++ Standards Meeting in Albuquerque, November 2017". There's Waldo!. 2017-11-20. Retrieved 2017-12-11.
  12. ^ "Wording for lambdas in unevaluated contexts" (PDF).
  13. ^ "Default constructible and assignable stateless lambdas" (PDF).
  14. ^ "Pack expansion in lambda init-capture". www.open-std.org. Retrieved 2017-12-11.
  15. ^ "String literals as non-type template parameters" (PDF).
  16. ^ Herb Sutter. "Trip report: Summer ISO C++ standards meeting (Rapperswil)".
  17. ^ "Support for contract based programming in C++". www.open-std.org. Retrieved 2018-11-10.
  18. ^ "Integrating feature-test macros into the C++ WD". www.open-std.org. Retrieved 2018-11-10.
  19. ^ "Bit-casting object representations". www.open-std.org. Retrieved 2018-11-10.
  20. ^ "explicit(bool)". www.open-std.org. Retrieved 2018-11-13.
  21. ^ "P0896R3" (PDF).
  22. ^ "P1141R1 - Yet another approach for constrained declarations".
  23. ^ "P1330R0 - Changing the active member of a union inside constexpr" (PDF).
  24. ^ "P1002R0 - Try-catch blocks in constexpr functions" (PDF).
  25. ^ "P1327R0 - Allowing dynamic_cast, polymorphic typeid in Constant Expressions".
  26. ^ "P1006R1 - Constexpr in std::pointer_traits" (PDF).
  27. ^ "P1032R1 - Misc constexpr bits".
  28. ^ "P1073R2 - Immediate functions".
  29. ^ "P1236R0: Alternative Wording for P0907R4 Signed Integers are Two's Complement".
  30. ^ "P1289R0 - Access control in contract conditions" (PDF).
  31. ^ "P0668R4: Revising the C++ memory model".
  32. ^ "N4649: Working Draft, Technical Specification on C++ Extensions for Coroutines" (PDF).
  33. ^ "Clang 5 Release Notes on coroutines".
  34. ^ "N4637: Working Draft, Extensions to C++ for Modules" (PDF).
  35. ^ "Clang 5 documentation on Modules".
  36. ^ "C++ Modules in VS 2015 Update 1".
  37. ^ "N3341: Transactional Language Constructs for C++" (PDF).
  38. ^ "Reflections on the reflection proposals - Meeting C++". meetingcpp.com. Retrieved 2017-06-30.
  39. ^ "Static reflection". www.open-std.org. Retrieved 2018-11-10.
  40. ^ Herb Sutter. "Metaclasses" (PDF).
  41. ^ "Atomic Smart Pointers".
  42. ^ "Functional in C++17 and C++20".
  43. ^ "P0342R0: Timing barriers".
  44. ^ "N4734: Working Draft, C++ Extensions for Networking" (PDF).
  45. ^ "N4685: Working Draft, C++ Extensions for Ranges" (PDF).
  46. ^ "Task Blocks".
  47. ^ "Text Formatting".

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