{"id":364095,"date":"2023-06-16T16:22:35","date_gmt":"2023-06-16T15:22:35","guid":{"rendered":"https:\/\/blog.jetbrains.com\/?post_type=rscpp&p=364095"},"modified":"2023-06-16T16:22:38","modified_gmt":"2023-06-16T15:22:38","slug":"resharper-cpp-2023-2-eap5","status":"publish","type":"rscpp","link":"https:\/\/blog.jetbrains.com\/rscpp\/2023\/06\/16\/resharper-cpp-2023-2-eap5\/","title":{"rendered":"ReSharper C++ 2023.2 EAP: Support for the C++23 Standard Library Modules"},"content":{"rendered":"

The new Early Access build is here with support for the C++23 standard library modules and C++20\u2019s [[no_unique_address]]<\/code> attribute, new code formatter settings, and other updates. Read on for more details and check out the full list of issues<\/a> we\u2019ve fixed in this update.<\/p>\n

You can download the EAP builds from our website or via the Toolbox App<\/a>.<\/p>\n

<\/i>DOWNLOAD RESHARPER C++ EAP<\/a><\/p>\n

C++20 and C++23 updates<\/h2>\n

The C++23 standard library introduces two named modules: std<\/code> and std.compat<\/code> (P2465<\/a>). You can now use import std<\/code> or import std.compat<\/code> to import the entire standard library instead of using a precompiled header or including specific headers for the parts of the standard library that you need. This way you\u2019ll also get all the usual benefits associated with the C++20 modules, including much faster compilation time and the absence of hidden dependencies on the standard library internals.<\/p>\n

In addition to shipping the source code for the std<\/code> and std.compat<\/code> modules in the standard library, Visual Studio 17.6 introduced a new setting that enables the automatic building of these modules when using the \/std:c++latest<\/code> switch (Project Properties | C\/C++ | Language | Build <\/em>IS<\/em>O C++23 Standard Library Modules<\/em>). As of this EAP build, ReSharper C++ will correctly resolve import<\/code> directives for standard library modules and automatically build the necessary ones. This makes it much easier to experiment with modules and benefit from improved compilation time (depending on the size of your project, of course).<\/p>\n

\"C++23<\/p>\n

C++20 added char8_t<\/code>, a new fundamental, unsigned integral type that stores one UTF-8 code unit. The recently accepted paper P2513<\/a> allows the initialization of a char<\/code> or unsigned char<\/code> array with a UTF-8 string literal. Visual Studio has supported this proposal since the 17.4 release, and now ReSharper C++ supports it as well. Interestingly, this change has also been backported to C++20 as a defect report. Yes, the language standard can have bug-fix updates too!<\/p>\n

\"Compatibility<\/p>\n

We\u2019ve also introduced support for the C++20\u2019s new [[no_unique_address]]<\/code> attribute, which can be used instead of relying on the empty base class optimization. [[no_unique_address]]<\/code> indicates that a unique address is not required for a non-static data member of a class (P0840<\/a>), allowing the compiler to lay out members of the class in a more efficient way. ReSharper C++ now takes [[no_unique_address]]<\/code> into account when calculating the size of an object.<\/p>\n

\"[[no_unique_address]]\"<\/p>\n

Code analysis<\/h2>\n

ReSharper C++ now highlights the #error<\/code> and #warning<\/code> diagnostic preprocessor directives according to their severity level:
\n\"#error<\/p>\n

We\u2019ve improved the evaluation engine to support aggregate initialization of constexpr<\/code> arrays.
\n\"aggregate<\/p>\n

This EAP build also brings a new compatibility inspection for forward declarations of C-style enums. Since the size of a C-style enum depends on its contents, the C++ standard forbids forward-declaring them without specifying the underlying type. MSVC, however, still accepts forward declarations like that, which can lead to non-portable code:<\/p>\n

\"ISO<\/p>\n

Code formatting<\/h2>\n

In this EAP build, we\u2019ve improved the formatting for bit-field members. The options to align initializers and declaration names in columns now support bit-fields. We\u2019ve also added two new formatter settings specifically for bit-fields:<\/p>\n