Early Access Program

ReSharper C++ 2023.2 EAP: Support for the C++23 Standard Library Modules

The new Early Access build is here with support for the C++23 standard library modules and C++20’s [[no_unique_address]] attribute, new code formatter settings, and other updates. Read on for more details and check out the full list of issues we’ve fixed in this update.

You can download the EAP builds from our website or via the Toolbox App.


C++20 and C++23 updates

The C++23 standard library introduces two named modules: std and std.compat (P2465). You can now use import std or import std.compat 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’ll 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.

In addition to shipping the source code for the std and std.compat 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 switch (Project Properties | C/C++ | Language | Build ISO C++23 Standard Library Modules). As of this EAP build, ReSharper C++ will correctly resolve import 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).

C++23 Standard Library Module

C++20 added char8_t, a new fundamental, unsigned integral type that stores one UTF-8 code unit. The recently accepted paper P2513 allows the initialization of a char or unsigned char 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!

Compatibility and portability fix for char8_t

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


Code analysis

ReSharper C++ now highlights the #error and #warning diagnostic preprocessor directives according to their severity level:
#error and #warning diagnostic preprocessor directives

We’ve improved the evaluation engine to support aggregate initialization of constexpr arrays.
aggregate initialization of constexpr arrays

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:

ISO C++ forbids forward enum declarations without underlying type

Code formatting

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

  • Spaces before and after the colon in bit-field declarations.
  • Alignment of bit-field sizes in columns.

formatting for bit-field members
Finally, there is a new setting to turn off indentation in member initializer lists.

Among other noteworthy updates, the Safe Delete refactoring now handles conflicts in dependent code. And for Unreal Engine 5.1 projects, we’ve introduced support for the UE_INLINE_GENERATED_CPP_BY_NAME macro, which lets you inline generated files into your module to improve compilation time. UE_INLINE_GENERATED_CPP_BY_NAME is now correctly handled when ordering #include directives, and it does not cause issues for the Rename refactoring.

That’s all for now! Please try out the new build and share your feedback with us. If you encounter any issues, don’t hesitate to report them to our issue tracker.


Your ReSharper C++ team
The Drive to Develop

image description