{"id":4733,"date":"2024-09-06T22:18:30","date_gmt":"2024-09-06T20:18:30","guid":{"rendered":"https:\/\/mariusbancila.ro\/blog\/?p=4733"},"modified":"2024-09-06T22:18:33","modified_gmt":"2024-09-06T20:18:33","slug":"whats-new-in-c26-part-1","status":"publish","type":"post","link":"https:\/\/mariusbancila.ro\/blog\/2024\/09\/06\/whats-new-in-c26-part-1\/","title":{"rendered":"What&#8217;s new in C++26 (part 1)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The C++26 version of the C++ standard is a work in progress, but a series of language and library features have been already added. Furthermore, some of them are already supported by Clang and GCC. One of these new changes was discussed in my previous article, <a href=\"https:\/\/mariusbancila.ro\/blog\/2024\/04\/21\/erroneous-behaviour-has-entered-the-chat\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Erroneous behaviour has entered the chat<\/a>. In this post, we will look at several language features added in C++26.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Specifying a reason for deleting a function<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Since C++11, we can declare a function as deleted, so that the compiler will prevent its use. This can be used to prevent the use of class special member functions, but also to delete any other function. A function can be deleted as follows (example from the proposal paper):<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class NonCopyable\n{\npublic:\n    \/\/ ...\n    NonCopyable() = default;\n\n    \/\/ copy members\n    NonCopyable(const NonCopyable&amp;) = delete;\n    NonCopyable&amp; operator=(const NonCopyable&amp;) = delete;\n    \/\/ maybe provide move members instead\n};<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In C++26, you can specify a reason why this function is deleted:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class NonCopyable\n{\npublic:\n    \/\/ ...\n    NonCopyable() = default;\n\n    \/\/ copy members\n    NonCopyable(const NonCopyable&amp;)\n        = delete(\"Since this class manages unique resources, copy is not supported; use move instead.\");\n    NonCopyable&amp; operator=(const NonCopyable&amp;)\n        = delete(\"Since this class manages unique resources, copy is not supported; use move instead.\");\n    \/\/ provide move members instead\n};<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The reason for having this feature is to help API authors to provide tailored messages for the removal of a function, instead of just relying on the generic compiler error for using a deleted function.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For more info see: <a href=\"https:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2024\/p2573r2.html\" target=\"_blank\" rel=\"noopener\" title=\"\">P2573R2: = delete(&#8220;should have a reason&#8221;);<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Placeholder variables with no name<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">There are cases when a variable has to be declared but its name is never used. An example is structure bindings. Another is locks (like <code>lock_guard<\/code>), that are only used for their side-effects. In the future, another example could be pattern matching (for which several proposals exist).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In C++26, we can use a single underscore (<code>_<\/code>) to define an unnamed variable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For instance, in the following example, <code>unused<\/code> is a variable that is not used:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[[maybe_unused]] auto [data, unused] = get_data();<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In C++26, the <code>unused<\/code> variable can be named <code>_<\/code> (single underscore):<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">auto [data, _] = get_data();<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When the single underscore identifier is used for the declaration of a variable, non-static class member variable, lambda capture, or structure binding, the <code>[[maybe_unused]]<\/code> attribute is implicitly added, therefore, there is no need to explicitly use it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A declaration with the name <code>_<\/code> is said to be <em>name-independent<\/em> if it declares:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>a variable with automatic storage duration<\/li><li>a structure binding, but not in a namespace scope<\/li><li>a variable introduced by an init capture<\/li><li>a non-static data member<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The compiler will not emit warnings that a name-independent declaration is used or not. Moreover, multiple name-independent declarations can be used in the same scope (that is not a namespace scope):<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">int main()\n{\n  int _;\n  _ = 0;         \/\/ OK\n\n  std::string _; \/\/ OK, because _ is a name-independent declaration\n  _ = \"0\";       \/\/ Error: ambiguous reference to placeholder '_', which is defined multiple times\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On the other hand, the following is not possible:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">int main()\n{\n  int _;\n  _ = 0;                \/\/ OK\n\n  static std::string _; \/\/ Error: static variables are not name-independent\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The following is also not possible, because the declarations are in a namespace scope:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">namespace n\n{\n  int f() {return 42;}\n\n  auto _ = f(); \/\/ OK\n  auto _ = f(); \/\/ Error: redefinition of _\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To learn more about this feature see: <a href=\"https:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2023\/p2169r4.pdf\" target=\"_blank\" rel=\"noopener\" title=\"\">P2169: A nice placeholder with no name<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Structured binding declaration as a&nbsp;condition<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A structure binding defines a set of variables that are bound to sub-objects or elements of their initializer.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">auto [position, length] = get_next_token(text, offset);<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A structure binding can appear in a for-range declaration, such as in the following example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">for (auto [position, length] : tokenize(text, offset))\n{\n  std::println(\"pos {}, len {}\", position, length);\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On the other hand, variables can appear in the condition of an <code>if<\/code>, <code>while<\/code>, or <code>for<\/code> statement:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">if (auto it = std::find_if(begin(arr), end(arr), is_even); it != std::end(arr))\n{\n  std::println(\"{} is the 1st even number\", *it);\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">However, structure bindings cannot be declared in the condition of an <code>if<\/code>, <code>while<\/code>, or <code>for<\/code> statement. That changes in C++26, which makes it possible:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">if(auto [position, length] = get_next_token(text, offset); position >= 0)\n{\n  std::println(\"pos {}, len {}\", position, length);\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">An interesting and very useful case is presented in the proposal paper (P0963). Consider the following C++26 example for using <code>std::to_chars<\/code>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">if (auto result = std::to_chars(p, last, 42))\n{\n\u200b\u200b\u200b\u200b    auto [ptr, _] = result;\n\u200b\u200b\u200b\u200b    \/\/ okay to proceed\n\u200b\u200b\u200b\u200b} \nelse \n{\n\u200b\u200b\u200b\u200b    auto [ptr, ec] = result;\n\u200b\u200b\u200b\u200b    \/\/ handle errors\n\u200b\u200b\u200b\u200b}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When the function succeeds, we are only interested in the <code>ptr<\/code> member of <code>std::to_chars_result<\/code>, which contains a pointer to the one-past-the-end pointer of the characters written. If the function fails, then we also need to look at the <code>ec<\/code> member (of the <code>std::errc<\/code> type) representing an error code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This code can be simplified with structure bindings, in C++26, as follows:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u200b\u200b\u200b\u200bif (auto [ptr, ec] = std::to_chars(p, last, 42))\n{\n\u200b\u200b\u200b\u200b    \/\/ okay to proceed\n\u200b\u200b\u200b\u200b} \nelse \n{\n\u200b\u200b\u200b\u200b    \/\/ handle errors\n\u200b\u200b\u200b\u200b}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To learn more about this feature see: <a href=\"https:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2024\/p0963r3.html\" target=\"_blank\" rel=\"noopener\" title=\"\">P0963: Structured binding declaration as a condition<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">user-generated static_assert messages<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>static_assert<\/code>&#8216;s second parameter, which is a string representing the error message, can now be a compile-time user-generated string-like object. The following example uses a hypothetical constexpr <code>std::format<\/code>, although this may also later appear in C++26:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">static_assert(sizeof(int) == 4, std::format(\"Expected 4, actual {}\", sizeof(int)));<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To learn more about this feature see: <a href=\"https:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2023\/p2741r3.pdf\" target=\"_blank\" rel=\"noopener\" title=\"P2471R3: user-generated static_assert messages\">P2471R3: user-generated static_assert messages<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The C++26 version of the C++ standard is a work in progress, but a series of language and library features have been already added. Furthermore, some of them are already supported by Clang and GCC. One of these new changes was discussed in my previous article, Erroneous behaviour has entered the chat. In this post, &#8230; <a title=\"What&#8217;s new in C++26 (part 1)\" class=\"read-more\" href=\"https:\/\/mariusbancila.ro\/blog\/2024\/09\/06\/whats-new-in-c26-part-1\/\" aria-label=\"Read more about What&#8217;s new in C++26 (part 1)\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","advgb_blocks_editor_width":"","advgb_blocks_columns_visual_guide":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[7],"tags":[451,647],"class_list":["post-4733","post","type-post","status-publish","format-standard","hentry","category-c","tag-c","tag-c26"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.3 - aioseo.com -->\n\t<meta name=\"description\" content=\"As C++26 is a work in process, we look at several new language features (already supported by Clang and GCC).\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Marius Bancila\"\/>\n\t<meta name=\"keywords\" content=\"c++,c++26\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/mariusbancila.ro\/blog\/2024\/09\/06\/whats-new-in-c26-part-1\/\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.3\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Marius Bancila&#039;s Blog | About code. Mostly on C++\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"What\u2019s new in C++26 (part 1)\" \/>\n\t\t<meta property=\"og:description\" content=\"As C++26 is a work in process, we look at several new language features (already supported by Clang and GCC).\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/mariusbancila.ro\/blog\/2024\/09\/06\/whats-new-in-c26-part-1\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2024-09-06T20:18:30+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2024-09-06T20:18:33+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"What\u2019s new in C++26 (part 1)\" \/>\n\t\t<meta name=\"twitter:description\" content=\"As C++26 is a work in process, we look at several new language features (already supported by Clang and GCC).\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2024\\\/09\\\/06\\\/whats-new-in-c26-part-1\\\/#article\",\"name\":\"What\\u2019s new in C++26 (part 1)\",\"headline\":\"What&#8217;s new in C++26 (part 1)\",\"author\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\"},\"datePublished\":\"2024-09-06T22:18:30+02:00\",\"dateModified\":\"2024-09-06T22:18:33+02:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2024\\\/09\\\/06\\\/whats-new-in-c26-part-1\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2024\\\/09\\\/06\\\/whats-new-in-c26-part-1\\\/#webpage\"},\"articleSection\":\"C++, C++, C++26\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2024\\\/09\\\/06\\\/whats-new-in-c26-part-1\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"name\":\"IT\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"position\":2,\"name\":\"IT\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"name\":\"Software\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"position\":3,\"name\":\"Software\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"name\":\"C++\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"name\":\"IT\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"position\":4,\"name\":\"C++\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2024\\\/09\\\/06\\\/whats-new-in-c26-part-1\\\/#listItem\",\"name\":\"What&#8217;s new in C++26 (part 1)\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"name\":\"Software\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2024\\\/09\\\/06\\\/whats-new-in-c26-part-1\\\/#listItem\",\"position\":5,\"name\":\"What&#8217;s new in C++26 (part 1)\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"name\":\"C++\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\",\"name\":\"Marius Bancila's Blog\",\"description\":\"About code. Mostly on C++\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/\",\"name\":\"Marius Bancila\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2024\\\/09\\\/06\\\/whats-new-in-c26-part-1\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a84dd2831d955c38355ddea55df4df260809b88f36408bc14fd4eab8f7f131c9?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Marius Bancila\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2024\\\/09\\\/06\\\/whats-new-in-c26-part-1\\\/#webpage\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2024\\\/09\\\/06\\\/whats-new-in-c26-part-1\\\/\",\"name\":\"What\\u2019s new in C++26 (part 1)\",\"description\":\"As C++26 is a work in process, we look at several new language features (already supported by Clang and GCC).\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2024\\\/09\\\/06\\\/whats-new-in-c26-part-1\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"datePublished\":\"2024-09-06T22:18:30+02:00\",\"dateModified\":\"2024-09-06T22:18:33+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\",\"name\":\"Marius Bancila's Blog\",\"description\":\"About code. Mostly on C++\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"What\u2019s new in C++26 (part 1)","description":"As C++26 is a work in process, we look at several new language features (already supported by Clang and GCC).","canonical_url":"https:\/\/mariusbancila.ro\/blog\/2024\/09\/06\/whats-new-in-c26-part-1\/","robots":"max-image-preview:large","keywords":"c++,c++26","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mariusbancila.ro\/blog\/2024\/09\/06\/whats-new-in-c26-part-1\/#article","name":"What\u2019s new in C++26 (part 1)","headline":"What&#8217;s new in C++26 (part 1)","author":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"publisher":{"@id":"https:\/\/mariusbancila.ro\/blog\/#organization"},"datePublished":"2024-09-06T22:18:30+02:00","dateModified":"2024-09-06T22:18:33+02:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/mariusbancila.ro\/blog\/2024\/09\/06\/whats-new-in-c26-part-1\/#webpage"},"isPartOf":{"@id":"https:\/\/mariusbancila.ro\/blog\/2024\/09\/06\/whats-new-in-c26-part-1\/#webpage"},"articleSection":"C++, C++, C++26"},{"@type":"BreadcrumbList","@id":"https:\/\/mariusbancila.ro\/blog\/2024\/09\/06\/whats-new-in-c26-part-1\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/mariusbancila.ro\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","name":"IT"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","position":2,"name":"IT","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","name":"Software"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","position":3,"name":"Software","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","name":"C++"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","name":"IT"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","position":4,"name":"C++","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/2024\/09\/06\/whats-new-in-c26-part-1\/#listItem","name":"What&#8217;s new in C++26 (part 1)"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","name":"Software"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/2024\/09\/06\/whats-new-in-c26-part-1\/#listItem","position":5,"name":"What&#8217;s new in C++26 (part 1)","previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","name":"C++"}}]},{"@type":"Organization","@id":"https:\/\/mariusbancila.ro\/blog\/#organization","name":"Marius Bancila's Blog","description":"About code. Mostly on C++","url":"https:\/\/mariusbancila.ro\/blog\/"},{"@type":"Person","@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author","url":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/","name":"Marius Bancila","image":{"@type":"ImageObject","@id":"https:\/\/mariusbancila.ro\/blog\/2024\/09\/06\/whats-new-in-c26-part-1\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/a84dd2831d955c38355ddea55df4df260809b88f36408bc14fd4eab8f7f131c9?s=96&d=mm&r=g","width":96,"height":96,"caption":"Marius Bancila"}},{"@type":"WebPage","@id":"https:\/\/mariusbancila.ro\/blog\/2024\/09\/06\/whats-new-in-c26-part-1\/#webpage","url":"https:\/\/mariusbancila.ro\/blog\/2024\/09\/06\/whats-new-in-c26-part-1\/","name":"What\u2019s new in C++26 (part 1)","description":"As C++26 is a work in process, we look at several new language features (already supported by Clang and GCC).","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/mariusbancila.ro\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/mariusbancila.ro\/blog\/2024\/09\/06\/whats-new-in-c26-part-1\/#breadcrumblist"},"author":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"creator":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"datePublished":"2024-09-06T22:18:30+02:00","dateModified":"2024-09-06T22:18:33+02:00"},{"@type":"WebSite","@id":"https:\/\/mariusbancila.ro\/blog\/#website","url":"https:\/\/mariusbancila.ro\/blog\/","name":"Marius Bancila's Blog","description":"About code. Mostly on C++","inLanguage":"en-US","publisher":{"@id":"https:\/\/mariusbancila.ro\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Marius Bancila's Blog | About code. Mostly on C++","og:type":"article","og:title":"What\u2019s new in C++26 (part 1)","og:description":"As C++26 is a work in process, we look at several new language features (already supported by Clang and GCC).","og:url":"https:\/\/mariusbancila.ro\/blog\/2024\/09\/06\/whats-new-in-c26-part-1\/","article:published_time":"2024-09-06T20:18:30+00:00","article:modified_time":"2024-09-06T20:18:33+00:00","twitter:card":"summary","twitter:title":"What\u2019s new in C++26 (part 1)","twitter:description":"As C++26 is a work in process, we look at several new language features (already supported by Clang and GCC)."},"aioseo_meta_data":{"post_id":"4733","title":null,"description":"As C++26 is a work in process, we look at several new language features (already supported by Clang and GCC).","keywords":null,"keyphrases":{"focus":[],"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","location":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2024-08-06 12:55:58","updated":"2026-10-18 15:43:44","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"author_meta":{"display_name":"Marius Bancila","author_link":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/"},"featured_img":null,"jetpack_publicize_connections":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Marius Bancila","author_link":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":"The C++26 version of the C++ standard is a work in progress, but a series of language and library features have been already added. Furthermore, some of them are already supported by Clang and GCC. One of these new changes was discussed in my previous article, Erroneous behaviour has entered the chat. In this post,&hellip;","coauthors":[],"tax_additional":{"categories":{"linked":["<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/\" class=\"advgb-post-tax-term\">C++<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">C++<\/span>"]},"tags":{"linked":["<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/\" class=\"advgb-post-tax-term\">C++<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/\" class=\"advgb-post-tax-term\">C++26<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">C++<\/span>","<span class=\"advgb-post-tax-term\">C++26<\/span>"]}},"comment_count":"0","relative_dates":{"created":"Posted 2 years ago","modified":"Updated 2 years ago"},"absolute_dates":{"created":"Posted on September 6, 2024","modified":"Updated on September 6, 2024"},"absolute_dates_time":{"created":"Posted on September 6, 2024 10:18 pm","modified":"Updated on September 6, 2024 10:18 pm"},"featured_img_caption":"","series_order":"","jetpack_shortlink":"https:\/\/wp.me\/pYNdv-1el","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/4733","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/comments?post=4733"}],"version-history":[{"count":9,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/4733\/revisions"}],"predecessor-version":[{"id":4742,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/4733\/revisions\/4742"}],"wp:attachment":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/media?parent=4733"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/categories?post=4733"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/tags?post=4733"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}