What’s New in ReSharper C++

ReSharper C++ 2021.3 helps you upgrade your code to modern C++, offers improved Unreal Engine support, and displays the evaluation results for constant expressions right in the Quick Info tooltip. It also includes support for Visual Studio 2022, which offers improved overall performance and responsiveness when working with large solutions.

Download

Free 30-day trial

Support for Visual Studio 2022

ReSharper C++ now supports the new Visual Studio 2022 release build, meaning you will have access to the same rich feature set you are used to using in other Visual Studio versions. Since Visual Studio 2022 is an x64 process, there is no longer a limit to the maximum amount of memory that can be allocated to it, and all the ReSharper С++ features work faster.

To work with ReSharper C++ in Visual Studio 2022, make sure that the VS2022 icon in the dotUltimate 2021.3 installer is selected.

C++20

You can use C++20 designated initializers to quickly generate boilerplate code for aggregate initialization (P0329). Just select the corresponding item from the completion list to insert designators for the data members, and then provide the initial values.

With the C++20 contains function, you can easily check whether an element exists in an associative container (P0458). A new inspection suggests replacing instances of find or count with the new contains member function.

The new standard brings convenient library functions for erasing elements that work for all standard containers (P1209). A dedicated inspection will let you know when an erase-remove idiom can be replaced with std::erase or std::erase_if.

Another new library addition is the smart pointer creation functions that perform default initialization (P1973). When you need to allocate an array of built-in types and then immediately initialize it, you can now apply a quick-fix to use make_shared_for_overwrite or make_unique_for_overwrite.

Unreal Engine

With ReSharper C++ 2021.3, you no longer need to switch to Unreal Editor to create a new class – all predefined templates for Unreal Engine classes are now available in the list of ReSharper file templates.

To create a new class, go to Solution Explorer and right-click on the preferred project folder to open the Add menu (or use Ctrl+Alt+Insert). After you choose an Unreal Engine template from the list and give your new class a name, ReSharper C++ will generate the header and source files with the template code in the proper folders depending on whether the folder is private or public.

ReSharper C++ now works correctly with the Unreal Engine Sparse Class Data system.

We’ve fixed an issue that would sometimes cause ReSharper to reindex source code when a solution was loading.

Code analysis

A new inspection marks redundant parentheses in lambdas with no parameters, since a parameter list is not required in such cases.

When an elaborated type specifier is used neither to declare a new class nor to refer to a previously declared but hidden class, ReSharper C++ will suggest removing the specifier.

A new inspection finds for loops that can be written in a more concise way as while loops. The accompanying quick-fix lets you quickly rewrite them.

User specializations of classes like std::hash or std::formatter are often wrapped in a standalone namespace. To make your code more readable, ReSharper C++ suggests using a qualified class name instead.

If you construct an object of an exception type but do not use it, ReSharper C++ now warns you and lets you quickly add the throw keyword.

The bundled Clang-Tidy has been updated to Clang 13, adding new checks from the latest LLVM release.

Coding assistance

The Quick Info tooltip now includes the evaluation results for constant expressions. You can use this feature to see what subexpressions of a failing static_assert expression evaluate to, or to check out the value of a sizeof or alignof operator.

In addition to the Document action (via the Alt+Enter menu or the Ctrl+/ shortcut), you can now generate a stub for a new documentation comment by typing /// before a function or another entity you want to document.

Navigation

The File Structure window now groups symbols with the same qualifier. This is especially useful in source files that contain a lot of out-of-class functions.

ReSharper C++ 2021.3 allows you to search for declarations in inactive code, where navigation was previously not available.

You can also now navigate from a goto statement to the corresponding label.

Change Signature

The Change Signature refactoring now lets you easily control the C++17 [[nodiscard]] attribute, which indicates that the function caller should use the function’s return value.

C support

ReSharper C++’s 2021.3 supports C11 _Generic expressions, which provide a mechanism for limited compile-time choices in C.

We’ve also introduced support for typeof – a GNU extension to the C language for referring to the type of an expression.

Take a look at What's New in ReSharper to learn about the other changes introduced in this release. For example, additional GitHub-related items in the Copy Code Reference pop-up make it easy to share links with people, and you can also add a custom URI template for non-GitHub repositories.

Download

Free 30-day trial

ReSharper C++ 2021.2

Type conversion hints

New inlay hints make hidden type conversions visible in the editor, so that you are aware of their potential performance and correctness implications.

You will see special icons for implicit conversions. Alternatively, you can choose to show the conversions as textual hints.

ReSharper C++ displays hints for different kinds of class type conversions, including object copying, object initialization using converting constructors or aggregate initialization, and calls to conversion operators.

You can also enable hints for standard conversions between built-in types, for example, conversions between numeric types that might lose precision or change the signedness of the type.

Immutability inspections

Immutability-related analyses can help you keep your code more readable and correct. By adding two new inspections, ReSharper C++ now covers all the rules from the Constants and immutability section of the C++ Core Guidelines.

The first new inspection extends the immutability analysis for function parameters of reference and pointer types. ReSharper C++ will notify you if you can pass a pointer or a reference to const, which guarantees that the function will not modify the corresponding function argument.

The second inspection suggests marking variables that can be evaluated at compile-time with constexpr, which can lead to faster performance and better compile-time checking.

Modernizing inspections

ReSharper C++ 2021.2 includes some new inspections to help you modernize your code.

Structured binding can be used instead of tie(..): since C++17, you no longer need to use std::tie() or boost::tie() for unpacking a tuple or a pair – structured binding declarations help you simplify your code.

Type trait can be simplified using a template alias or a variable template: C++14 alias templates let you shorten C++11 type trait expressions.

std::size can be used: this inspection suggests using std::size as a type-safe alternative to the error-prone C idiom for array size calculation.

Zero initialization can be used instead of memset: zero-initialization leads to more concise code and prevents various memset-related errors.

Inline Function refactoring

The new Inline Function refactoring lets you quickly replace a function call with the body of the function. To invoke it, place the caret on a function call and select Inline Function from the Refactor This menu, or choose ReSharper | Refactor | Inline from the main menu. ReSharper C++ will perform the necessary transformations, handle all the name conflicts, and reformat the resulting code.

Coding assistance

By default, ReSharper C++ generates functions with empty bodies, but now you can specify whether the generated functions should throw an std::logic_error, return a default value, or include uncompilable code. To configure this, go to ReSharper | Options | Code Editing | C++ | Code Generation. ReSharper C++ will also automatically call the base function from the body of an overriding function.

A new context action lets you convert any string into a C++11 raw string literal, which is easier to read when the string literal contains special characters. The transformation works both ways, so you can convert a raw string literal into a regular string literal, too.

If you want to quickly consult cppreference.com about the details of a standard library class or function, you can now click Read more in the Quick Documentation pop-up (Ctrl+Shift+F1) to open the corresponding page in your browser.

When you press Backspace on an empty line or a line with whitespaces or tabs to the left of the caret, ReSharper C++ can now place the caret at the proper indent position instead of moving it back one position at a time.

Unreal Engine

ReSharper C++ 2021.2 supports working with Unreal Engine 5 from both the Unreal Launcher and GitHub sources.

In the .Build.cs and .Target.cs files of an Unreal Engine project, ReSharper C++’s code completion now suggests the list of available modules and plugins.

After you’ve added a module or a plugin, the new inspection for missing dependencies will highlight any that must be referenced in the .uproject or .uplugin file. Use the accompanying quick-fix to add new modules and plugins to the project files with a single click.

When generating a definition of an overriding function, ReSharper C++ will now call the overridden function from the generated body using the idiomatic Super type alias.

We've improved the performance and memory usage of a cold startup. Now ReSharper C++ indexes the Unreal Engine codebase 10% faster.

Other changes

The bundled Clang-Tidy has been updated to Clang 12, adding new checks from the latest LLVM release. We’ve also improved its performance in complex files, particularly in C++20 projects.

A new inspection warns you when you compare an unsigned expression with 0, which may cause an infinite loop or unreachable code.

Take a look at What's New in ReSharper to learn about the other changes coming to the ReSharper platform. For example, the InspectCode command line tool now restores NuGet packages and builds a solution before starting its analysis.

ReSharper C++ 2021.1

C++ Support

Class types

ReSharper C++ 2021.1 adds support for class types in non-type template parameters. With this C++20 feature, you can use your own classes in the types of template parameters when the class satisfies certain requirements.

CTAD

Another useful addition is the support for C++20 CTAD rules: class template argument deduction now works for aggregate templates, type aliases, and inherited constructors.

Noexcept

Since C++17, the noexcept specification has been considered a part of the function type, and ReSharper C++ now fully supports the new exception specification semantics.

Coroutines

Up until now, code completion didn't include support for the C++20 coroutines-related syntax. Now co_await, co_yield, and co_return are available both in basic code completion and as postfix completion templates.

Code Analysis

Limit scope

ReSharper C++ will now notify you when a variable is declared before the scope in which it's used. In this case, you can use the provided quick-fix to move the variable and limit its scope.

Redundant cast

Another new inspection detects redundant cast expressions, which can be safely eliminated from code without changing its semantics.

Conversion error

ReSharper C++ 2021.1 includes new quick-fixes for conversion errors: choose one of the conversions suitable for the current context (c_str(), to_string(), etc.) to resolve the error.

Redundant template arguments

ReSharper C++ 2021.1 also highlights redundant template arguments that can be deduced by the language according to the C++17 class template argument deduction rules.

Syntax Style

With the 2021.1 release, we've introduced a collection of syntax style settings that you can use to make ReSharper follow your chosen code style and enforce it throughout your entire codebase.

You can customize your syntax style preferences on the Code Editing | C++ | Syntax Style page. The selected option value will be used both for code generation and for code style enforcement.

Quick-fix

ReSharper C++ will highlight style violations and offer you quick-fixes to help eliminate them. All syntax style quick-fixes can be applied in scope, including in local scopes like function bodies or class definitions.

Context actions

Enabling all the style inspections can be overwhelming, so we've made sure that context actions are always available for tuning your code even if you’ve muted the corresponding inspections.

Apply syntax style

To enforce the chosen syntax style, you can use code cleanup or the dedicated Apply Syntax Style action, which will fix syntax style issues in the selection, the entire current file, or a set of files depending on the current context.

Declaration Style

Several new syntax style settings let you configure and enforce the style of declarations in your code.

You can choose whether to prefer typedefs or use alias declarations instead. In function declarations, you can enforce trailing return types or configure ReSharper C++ to require regular return types. You can also specify whether to use C++17 nested namespace definitions where possible.

You can specify when ReSharper C++ should require auto instead of an explicit type in variable declarations. By default, auto is now suggested only when the deduced type is evident from the surrounding context.

Const

Syntax style settings for the position of cv-qualifiers let you choose the east const or the west const style, and quickly update your code to use one or another.

Override

You can also choose which of the virtual and override specifiers (or both) should be used on overriding functions and destructors.

Braces style

Require braces

In C++ braces can be omitted around single nested statements, but code style guidelines may still require braces in certain cases. To help you enforce the braces style, ReSharper C++ adds syntax style rules for the use of braces.

Remove redundant braces

You can choose whether to always enforce braces, or you can require braces only for multi-line statements or around multi-line statement bodies. ReSharper C++ can also find and remove redundant braces that do not conform to the chosen braces style.

Code Cleanup

Cleanup profile

All the new syntax style checks have received a corresponding code cleanup option and can be disabled in custom profiles. There are also two new options to remove redundant casts and template argument lists.

Cleanup selection

The new Cleanup selection context action lets you quickly run code cleanup on the selected code range. You can also conveniently choose one of the custom code cleanup profiles to use during the run.

Finally, we've improved the performance of code cleanup. In many cases, code cleanup now spends less time analyzing code and performs fewer operations, finishing faster on real-world codebases.

Unreal Engine

We've introduced initial support for Unreal Engine 5 based on feedback from the Epic Games team.

UE Cast

Unreal Engine's Cast for type-safe dynamic casting is now available as a postfix template in code completion.

RIGVM_METHOD

ReSharper C++ adds support for another Unreal Engine specific reflection macro, RIGVM_METHOD, and now handles it correctly.

Other changes

Take a look at What's New in ReSharper to learn about other changes coming to the ReSharper platform. For example, there is a new navigation action, Navigate to Windows Explorer, and an action for creating links to GitHub sources with the Copy FQN feature.