C++20 modules

ReSharper C++ 2022.3 adds experimental support for arguably the most significant update to C++ since the original C++98 standard: C++20 modules. Modules introduce a new compilation model, where instead of using header files, you split your code into independently compiled components.

In new code, you should use named modules, which explicitly declare their interface in .ixx module interface files. But in order to make the transition easier, C++20 also provides a way to use existing, well-behaved header files as modules through header units. Both ways to create and consume modules are now supported by ReSharper C++.

First of all, ReSharper C++ now properly handles the new syntax: module declarations that introduce modules and module partitions, import declarations that consume other modules, and the export of entities from module interfaces. And like it does for include directives, ReSharper C++ will warn you about unresolved module names or paths in import declarations.

In code navigation, all the features you’re used to now work for entities imported from modules. With support for module declarations, you can now use Go to Declaration on the module name in import declarations, navigate to module declarations from File Structure, and search for modules with Go to Symbol.

If you want to quickly create a module, you can use a new built-in file template – Module interface unit. To create a new file from a file template, use the Ctrl+Alt+Insert shortcut or select ReSharper | Edit | Create New File from the main menu.

Among the features that benefit from modules support is code completion. The code completion list now includes items from all the imported modules and header units.

This is still a work in progress, and there are some known limitations. Learn more.

C++ support

We’ve introduced support for the #pragma pack directive, which modifies the current alignment for classes and structures. ReSharper C++ now correctly computes the size of packed structures.

In ReSharper C++ 2022.2, we implemented a lot of improvements for working with emplace-like and make-like function calls. However, these features were limited to classes and functions from the standard library. In this release, ReSharper C++ can show you parameter info and inlay hints for any similar function defined in your code.

To let ReSharper C++ know that a function implies a constructor call, make sure that the function template parameter is constrained (using SFINAE or a requires clause) to be constructible from the given arguments pack.

ReSharper C++ 2022.3 introduces support for the extended C++20 version of [[nodiscard]], which includes a reason why a function or a class has been marked with the attribute. Now you’ll get a clearer warning with the specified reason when the result of a function call is not used.

This release also brings improvements for compile-time evaluation. ReSharper C++ now correctly handles various forms of object initialization, including the evaluation of constructors of any kind – default, implicitly generated, inherited, and user-defined.

We’ve also improved the support for calling conventions. ReSharper C++ now understands the GNU style for specifying calling conventions in function declarations for compilers that support this syntax (void __attribute__((stdcall)) bar()).

Unreal Engine

If an asset is affected by renaming a symbol, Unreal Engine will no longer recognize it. To prevent data loss, ReSharper C++ suggests adding a Core Redirect when you perform the Rename refactoring. If accepted, the corresponding .ini file is updated automatically.

The Add Core Redirect option was already available for UCLASS and UPROPERTY, and now it also works for UFUNCTION, USTRUCT, and UENUM.

ReSharper C++ 2022.3 introduces a new Blueprint-specific inlay hint. You can now quickly check how many blueprints use a function marked with the BlueprintCallable specifier and get a list of all usages from the hint’s context menu.

ReSharper C++ no longer offers unwanted entities from system headers and shader files in auto-import suggestions. You can enable system header suggestions in Options | Code Editing | C++ | Unreal Engine.

ReSharper C++ 2022.3 also includes updates for the latest Unreal Engine 5.1 version.

If you are interested in a stand-alone cross-platform IDE for Unreal Engine development, consider Rider. Unreal Engine support in Rider and ReSharper C++ is aligned, and you can expect the same improvements in the Rider 2022.3 update.

Code formatting

ReSharper C++ 2022.3 provides seamless integration with clang-format as an alternative code formatter. You can now switch between ReSharper’s own formatting engine and сlang-format when formatting files.

ReSharper C++ runs the clang-format binary in a separate process, ensuring full compatibility with the industry-standard formatter, as well as better performance and a more extensive range of formatting options.

By default, ReSharper C++ uses the built-in clang-format binary. You can configure ReSharper C++ to run any other clang-format binary on the Code Editing | C++ | Formatting Style | General page of the ReSharper options.

For those who prefer ReSharper’s own formatter or would like to quickly set up the formatting style via Detect formatting settings, ReSharper C++ 2022.3 introduces some new formatting options to configure:

  • Spaces before and after ellipses (…) in parameter packs.
  • The number of blank lines that are acceptable in declarations and in the rest of the code.
  • Whether blank lines are kept or removed after an opening brace ({) and before a closing one in declarations and in the rest of the code.
  • Blank lines before and after access specifiers.
  • Alignment of enumerator initializers in columns.

Coding assistance

ReSharper C++ now shows the origin of a function in parameter info and other tooltips, identifying whether a function is implicitly generated (e.g. constructors or assignment operators), built-in (e.g. operator + for fundamental types), or a compiler intrinsic (e.g. functions with the __builtin_ prefix).

There are two useful new additions to help you make conditions more readable:

  • A context action that replaces && with || and vice versa inside boolean expressions, following De Morgan’s laws.
  • An inspection with a quick-fix that simplifies negated comparison expressions.

We’ve also updated the bundled Clang-Tidy binary to Clang 15, adding new checks from the latest LLVM release.

Take a look at What's New in ReSharper to learn about the other changes introduced in this release. For example, ReSharper now alerts you about vulnerable dependencies associated with the use of NuGet packages.