C++23
C++ language revisions |
---|
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
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
forstd::basic_string
andstd::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 fromstd::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()
andstd::inout_ptr()
.[26]constexpr
forstd::optional
,std::variant
,[27] andstd::type_info::operator==
.[28]- Iterators pair constructors for
std::stack
(stack) andstd::queue
(queue).[29] - Few changes of the ranges library:
- Prohibiting
std::basic_string
andstd::basic_string_view
construction fromnullptr
.[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)
orauto{x}
.[47] - Changes in text formatting library:
- Addition of type alias
std::pmr::stacktrace
which is equivalent tostd::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 templatesstd::ranges::istream_view
,std::ranges::wistream_view
, and customization point objectstd::views::istream
.[52] zip
range adaptor family:[53]zip_view
zip_transform_view
adjacent_view
(andstd::views::pairwise
being equivalent tostd::views::adjacent<2>
)adjacent_transform_view
(andstd::views::pairwise_transform
being equivalent tostd::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
andstd::basic_string_view
is trivially copyable.[60] - Adding conditional
noexcept
specifications tostd::exchange
.[61] - Revamped specification and use of integer-class types.[62]
- Moving the deprecation of C headers to the main standard for interoperability with C.[63]
After the virtual WG21 meeting of 07 February 2022, the following features are added where they were approved by straw polls:[64]
- std::expected (PR0323R12)
- constexpr for cmath and cstdlib (PR0533R9)
- Function to mark unreachable code (P0627R6)
- ranges::to (PR1206R7)
- Deprecate std::aligned_storage and std::aligned_union (PR1413R3)
- P2255R2 (A type trait to detect reference binding to temporary)
- P2273R3 (Making std::unique_ptr constexpr)
- P2387R3 (Pipe support for user-defined range adaptors)
- P2440R1 (ranges::iota, ranges::shift_left and ranges::shift_right)
- P2441R2 (views::join_with)
- P2442R1 (Windowing range adaptors: views::chunk and views::slide)
- P2443R1 (views::chunk_by)
Removed feature
- Garbage collection support.[65]
References
- ^ "Working Draft, Standard for Programming Language C++" (PDF). 2022-03-17.
- ^ 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.
- ^ 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.
- ^ "Evolving C++ remotely".
- ^ a b Sutter, Herb (29 July 2020). "Business Plan and Convener's Report: ISO/IEC JTC1/SC22/WG21 (C++)" (PDF).
- ^ a b c "Upcoming Meetings, Past Meetings".
- ^ Ranns, Nina (2020-11-19). "WG21 2020-11 Virtual Meeting: Minutes of Meeting" (PDF).
- ^ JeanHeyd Meneide; Rein Halbersma (2019-11-24). "Literal Suffix for (signed) size_t".
- ^ Wim Leflere; Paul Fee (2020-06-13). "string contains function".
- ^ Alexey Gorgurov; Antony Polukhin (2020-09-16). "A Proposal to add stacktrace library".
- ^ Juan Alday (2020-10-12). "A proposal for a type trait to detect scoped enumerations" (PDF).
- ^ Hans-J. Boehm (2020-10-23). "P0943R6: Support C atomics in C++".
- ^ Ranns, Nina (2021-02-22). "WG21 2021-02 Virtual Meeting: Minutes of Meeting" (PDF).
- ^ Tim Song (2021-01-12). "Repairing input range adaptors and counted_iterator".
- ^ Alex Christensen; JF Bastien (2020-12-11). "P1102R2: Down with ()!".
- ^ Alexey Dmitriev; Howard Hinnant (2020-10-22). "Relax Requirements for time_point::clock".
- ^ Barry Revzin (2020-10-30). "Inheriting from std::variant".
- ^ Tim Song (2020-11-13). "Locks lock lockables".
- ^ Barry Revzin (2020-02-19). "Conditionally borrowed ranges".
- ^ JeanHeyd Meneide (2021-01-22). "std::to_underlying for enumerations".
- ^ Ranns, Nina (2021-06-07). "WG21 2021-06 Virtual MeetingMinutes of Meeting" (PDF).
- ^ Barry Revzin; Richard Smith; Andrew Sutton; Daveed Vandevoorde (2021-03-22). "if consteval".
- ^ Andrzej Krzemieński (2021-04-12). "Narrowing contextual conversions to bool".
- ^ Erich Keane (2020-07-02). "Allow Duplicate Attributes" (PDF).
- ^ Peter Sommerlad (2021-02-26). "A strstream replacement using span<charT> as buffer" (PDF).
- ^ JeanHeyd Meneide; Todor Buyukliev; Isabella Muerte (2021-04-15). "out_ptr - a scalable output pointer abstraction".
- ^ Barry Revzin (2021-02-11). "Missing constexpr in std::optional and std::variant".
- ^ Peter Dimov (2021-05-01). "Making std::type_info::operator== constexpr".
- ^ Corentin Jabot (2021-03-05). "Iterators pair constructors for stack and queue" (PDF).
- ^ Christopher Di Bella (2021-02-19). "starts_with and ends_with".
- ^ Barry Revzin (2021-03-05). "Superior String Splitting".
- ^ Tim Song (2021-05-06). "join_view should join all views of ranges".
- ^ Barry Revzin (2021-05-14). "Views should not be required to be default constructible".
- ^ Corentin Jabot (2021-03-17). "Range constructor forstd::string_view 2: Constrain Harder" (PDF).
- ^ Yuriy Chernyshov (2020-09-06). "A Proposal to Prohibit std::basic_string and std::basic_string_view construction from nullptr".
- ^ Zhihao Yuan (2020-04-29). "invoke_r".
- ^ Victor Zverovich (2021-02-05). "std::format improvements".
- ^ Logan R. Smith (2021-01-25). "Default Arguments for pair's Forwarding Constructor".
- ^ Ranns, Nina (2021-10-04). "WG21 2021-10 Virtual Meeting Minutes of Meeting" (PDF).
- ^ Ville Voutilainen (2021-07-12). "Non-literal variables (and labels and gotos) in constexpr functions".
- ^ Gašper Ažman; Sy Brand; Ben Deane; Barry Revzin (2021-07-12). "Deducing this".
- ^ Corentin Jabot (2021-09-14). "Consistent character literal encoding" (PDF).
- ^ Jens Maurer (2021-09-21). "Character sets and encodings".
- ^ Melanie Blower (2021-04-30). "Add support for preprocessing directives elifdef and elifndef" (PDF).
- ^ Jens Maurer (2021-04-13). "Extend init-statement to allow alias-declaration".
- ^ Mark Hoemmen; Daisy Hollman; Corentin Jabot; Isabella Muerte; Christian Trott (2021-09-14). "Multidimensional subscript operator" (PDF).
- ^ Zhihao Yuan (2021-07-12). "auto(x): decay-copy in the language".
- ^ Victor Zverovich; Corentin Jabot (2021-09-11). "Fixing locale handling in chrono formatters".
- ^ Victor Zverovich (2021-09-24). "Add support for std::generator-like types to std::format".
- ^ Steve Downey (2021-06-14). "Add a pmr alias for std::stacktrace".
- ^ Barry Revzin; Tim Song (2021-08-15). "What is a view?".
- ^ Nicolai Josuttis (2021-09-24). "Fix istream_view" (PDF).
- ^ Tim Song (2021-06-11). "zip".
- ^ Matt Calabrese; Ryan McDougall (2021-07-09). "move_only_function".
- ^ Sy Brand (2021-04-27). "Monadic operations for std::optional".
- ^ Chris Kennelly; Mark Zeren (2021-09-14). "basic_string::resize_and_overwrite".
- ^ Bryce Adelstein Lelbach (2021-09-25). "Printing volatile Pointers".
- ^ Isabella Muerte; Corentin Jabot (2021-09-17). "Byteswapping for fun&&nuf".
- ^ Konstantin Boyarinov; Sergey Vinogradov; Ruslan Arutyunyan (2020-12-15). "Heterogeneous erasure overloads for associative containers".
- ^ Nevin Liber (2021-03-19). "Require span & basic_string_view to be TriviallyCopyable" (PDF).
- ^ Giuseppe D'Angelo (2021-06-28). "Add a conditional noexcept specification to std::exchange".
- ^ Tim Song (2021-08-06). "Cleaning up integer-class types".
- ^ Thomas Köppe (2021-06-11). "Clarifying the status of the "C headers"".
- ^ Ranns, Nina (2022-02-07). "WG21 2022-02 Virtual Meeting: Minutes of Meeting" (PDF).
- ^ JF Bastien; Alisdair Meredith (2021-04-16). "Removing Garbage Collection Support".