C++23
From cppreference.com
< cpp
The current revision of the C++ standard.
| This section is incomplete Reason: Check that all significant features are mentioned (using the Compiler Support tables below). Add more links and maybe regroup some lines. |
New language features
- New language feature testing macros
- Explicit object parameter, explicit object member functions, a.k.a. "deducing
this" (P0847R7) - Multidimensional subscript operator (e.g.
v[1, 3, 7] = 42;) (P2128R6) static operator[](P2589R1),static operator(), and static lambdas (P1169R4)auto(x)andauto{x}: decay-copy in the language (P0849R8)- Assumptions via new attribute
[[assume(expression)]](P1774R8) - Attributes on lambda-expressions (P2173R1)
- Optional extended floating-point types:
std::float{16|32|64|128}_t, andstd::bfloat16_t(P1467R9) - New preprocessor directives:
#elifdef,#elifndef(P2334R1), and #warning (P2437R1) - Literal suffix '
Z'/'z' for (signed)std::size_tliterals (P0330R8), e.g.auto ouz = 0uz; - White-spaces trimming before line splicing. (P2223R2)
- Simpler implicit move (P2266R3)
- Extending the lifetime of temporaries in range-based for loop initializer (P2718R0)
- CTAD from inherited constructors (P2582R1)
- Labels at the end of compound statements (P2324R2), e.g.
void f(int& x){if (x)goto END;x = 42;END:}
- Alias declarations (
using) in init-statements (P2360R0), e.g.
for (using T = int; T e : v)/* ... */
- Make
()more optional for lambda expressions (P1102R2) - Narrowing contextual conversions to
boolinstatic_assertandif constexpr(P1401R5) - Make declaration order layout (of non-static class data members) mandated (P1847R4)
- Text encoding changes:
- Character sets and encodings (P2314R4)
- Consistent character literal encoding (P2316R2)
- Named universal character escapes, e.g.
"\N{CAT FACE}"for"🐱"(P2071R2) - Delimited escape sequences, e.g.
"\o{7777}","\x{C0DE}","\u{CAFE}"(P2290R3) - Support for UTF-8 as a portable source file encoding (P2295R6)
- if consteval / if not consteval (P1938R3)
constexprchanges:- Non-literal variables, labels, and
gotos inconstexprfunctions (P2242R3) - Permitting
staticandthread_localvariables in constant expressions inconstexprfunctions (P2647R1) constexprfunction does not need its return type and parameter types to be literal type (P2448R2)constexprfunction for which no invocation satisfies the requirements of a core constant expression (P2448R2)
- Non-literal variables, labels, and