What’s New in ReSharper C++

ReSharper C++ 2021.1 brings support for several new C++20 and C++17 language features, adds new inspections, and improves Unreal Engine support. You can now configure ReSharper C++ to match your code style even more closely with a new set of syntax style settings. The accompanying quick-fixes and context actions help you keep your code style consistent and update your code with ease.

Download

Free 30-day trial

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.

Download

Free 30-day trial

ReSharper C++ 2020.3

Unreal Engine

ReSharper C++ 2020.3 provides seamless integration with UnrealHeaderTool to help you catch more issues with Unreal Engine class metadata right in the editor. When working with an Unreal Engine project, ReSharper C++ automatically runs UnrealHeaderTool on the file you’re editing and displays any errors or warnings, just like with other inspections. Watch the UnrealHeaderTool integration in action.

UE update model

To always keep you up to date, ReSharper C++ now tracks Unreal Engine properties in real time and regenerates the project model as soon as you save any changes in .Build.cs, .Target.cs, .uproject, or .uplugin files.

Unreal Engine model

ReSharper C++ 2020.3 improves its conformance to the Unreal Engine coding standard. For example, ReSharper C++ now suggests using MoveTemp (Unreal Engine's equivalent of std::move) for casting to an rvalue reference.

C++20 Comparisons

ReSharper C++ 2020.3 fully supports C++20 comparison rules. This includes a significant change to how comparisons work, where the language is allowed to rewrite a comparison expression or reverse the order of arguments. You can now consult the tooltip to learn how an expression has been rewritten. When a comparison operator cannot be resolved, the error message will list all the considered overloading candidates.

Defaulted comparison operators are another addition to C++20. If you are not sure why a defaulted comparison operator in your class has been implicitly deleted, you can check the detailed tooltip message to find out the exact reason. ReSharper C++ can now also deduce the return type of a defaulted three-way comparison operator.

IncludeCompareFix

A new quick-fix lets you quickly add an #include <compare> directive to your source file, which is required whenever you use a three-way comparison operator that returns a standard comparison category, such as std::strong_ordering.

CreateOperatorFix

The Create operator from usage quick-fix has been updated to support C++20 comparison rules as well. You can now create both the member and the friend versions of an operator in addition to the non-member version. For secondary operators, which can be rewritten in terms of a primary one, you can choose to create either the primary or the secondary operator.

Code analysis

The full power of ReSharper's control-flow analysis now comes to HLSL shader files, including warnings about unreachable code, uninitialized variables, redundant control flow jumps and conditional branches, and much more.

ReSharper C++ 2020.3 offers two inspections with quick-fixes to help you adopt the new C++20 ranges library and modernize your code:

  • An algorithm operating on ranges can be used.
  • std::views::keys/values can be used.
Algorithms quick-fixes

A new inspection suggests replacing usages of standard algorithms that accept a pair of iterators with equivalent algorithms that accept an iterator and a count where possible.

Clang-Tidy

The bundled Clang-Tidy binary has been updated to Clang 11, adding new checks and compiler diagnostics from the latest LLVM release.

Push-to-Hint inlay hints

Push-to-Hint

ReSharper C++ provides many kinds of inlay hints. While all of the hints are useful in certain scenarios, we’ve also heard feedback that sometimes they can be overwhelming. To help address this, we’ve come up with a new "Push-to-Hint" mechanism for inlay hints. In the Push-to-Hint visibility mode, hints are only shown when you either press and hold Ctrl, or press Ctrl twice.

Hint visibility

We've made sure that the visibility mode can be configured separately for every kind of C++ inlay hint. You can quickly change the visibility mode for a given hint using the context menu, or head to the new option pages under Environment | Inlay Hints | C++ to check out all the settings.

Code completion

Invert ternary

A new context action helps you invert ternary operator expressions.

Join declaration and assignment

The "Join declaration and assignment" quick-fix is now available for cases when a local variable is reassigned in all paths before being read.

With import completion enabled, the completion list will suggest suitable members of incomplete classes from the header files that are not included in the current file.

Import completion now also suggests a new option to add an elaborated type specifier for the corresponding class, in addition to the options to add an include directive or a forward declaration.

Code completion

We've improved argument code completion for library functions that accept macro constants. Library macro constants that are applicable to the current argument are now prioritized in the completion list. This heuristic works for functions from the standard library, WinAPI, and OpenGL.

Navigation and Search

Fuzzy search

In addition to its regular search, Find Text now performs a fuzzy search, which means it takes possible typos and missing words into account. This feature can be very helpful if you are looking for a certain format string used as an argument to a text formatting function like printf or std::format.

Navigation between preprocessor directives

You can now use Go to Declaration to jump between matching preprocessor directives, such as branches of a conditional preprocessing block, or the #define and #undef of the same macro in a single file.

Go to Declaration can also be used to quickly navigate to a base function – just invoke it on an override keyword.

Peek Implementations and Peek Base Symbols come to C++, allowing you to view and edit code in a popup window without switching away from the code you're writing.

File structure

For better readability, File Structure now uses the C++17 syntax for nested namespaces even if you have not yet adopted the new syntax in your codebase.

Go to Derived Symbols

Go to Derived Symbols works for get/set functions inside C++/CLI properties and for add/remove functions inside C++/CLI events.

Other changes

  • C++20 support has been improved according to the standard conformance updates in Visual Studio 16.8. In particular, ReSharper C++ now supports both the standard and the extension modes for C++ coroutines, along with the new <coroutine> header.
  • Thanks to the reduced search scope, we’ve been able to boost the performance of Find Usages and Rename when these actions are used on private class members.

Take a look at What's New in ReSharper to learn about other changes coming to the ReSharper platform. For example, command-line tools now support plugins, and you can invoke CleanupCode on a specific set of files or folders instead of the whole solution.

ReSharper C++ 2020.2

Unreal Engine

Unreal Engine

To increase the accuracy of auto-import and code completion, ReSharper C++ 2020.2 introduces support for the Unreal Engine project model. This means that ReSharper C++ is now able to read project information directly from .uproject files, without using the intermediary project files generated by Visual Studio. The new project model provides more refined lists of suggested items that depend on the plugin and module references. ReSharper C++ will also adjust its behavior when you switch the solution configuration.

ReSharper C++ will now also remind you to refresh your Visual Studio project in Unreal Editor if the project files are out of date.

Unreal Engine

For easier navigation, symbols from engine sources are now treated as library symbols and will be hidden by default from the search results if there is a matching symbol in user code.

Unreal Engine

To match the Unreal Engine coding standard, ReSharper C++ 2020.2 includes several updates to inspection severity, code generation actions, and auto-import of include directives.

Also, a new inspection with a quick-fix is available for adding the virtual specifier to overriding functions.

C++/CLI

ReSharper C++ 2020.2 includes a lot of bug fixes and brings improved interoperation of C++/CLI with C#. When looking for derived symbols in C++/CLI code, ReSharper C++ finds symbols in C# code in addition to symbols in C++/CLI. Navigation to base and derived symbols also works on imported CLR entities.

New code inspections with quick-fixes are available for the gcnew, sealed, and safe_cast usages.

Navigation and Search

Navigation

The following features have had their their scope and applicability extended:

  • Go to declaration works on unresolved identifiers to help you understand what went wrong.
  • Find usages finds constructor usages from braced init lists in more cases, including return statements. Find usages has also received a performance boost thanks to several fixes.
  • Go to Base Symbols and Go to Derived Symbols now work on imported CLR entities.
Navigation and Search

ReSharper C++ can now automatically highlight usages of the element under the caret as you move through your code.

In the File Structure window, preprocessor directives are now hidden by default so you can navigate through large files more easily.

Code analysis

Code analysis

New inspections are available with corresponding quick-fixes that help you with the following cases:

  • Structured bindings can be used to modernize the code.
  • Overriding function does not have a virtual specifier.
  • Cannot use gcnew on a native type and cannot use new on a managed type.
  • The final specifier cannot be used for managed classes.
Code analysis

ReSharper C++ now also highlights spelling mistakes for preprocessor directives.

With a brief preview of Clang-Tidy quick-fixes, it's now easier to select the required fix option.

Code analysis

The evaluation engine has been updated with support for the modification of values inside constexpr functions and can work with the values of class types.

Code completion

Code completion

A new completion item can insert an auto-generated lambda argument when a std::function parameter is expected.

Code completion

If a class is not included in the current file, import completion will suggest a new option to add a forward declaration instead of including the corresponding header file.

Code style and formatting

Code style and formatting

ReSharper C++ 2020.2 adds three new settings for more flexible configuration:

  • Indent aligned ?: operator – a formatting option for multiline ternary expression.
  • Insert // on Enter in multi-line // comments – an editor option to prevent the auto-extension of multi-line comments in single-line style.
  • Consider only quoted includes as potential main headers – an option for sorting include directives to improve main header detection.
Code completion

The #include ordering settings have been moved to a separate options page and are now easier to find – just click Order of #includes under the Code Editing | C++ option group.

Last but not least, the formatting engine now works significantly faster in source files with many macro calls.

There are more updates from ReSharper itself. For example, code cleanup can now be launched automatically on save or applied only to the changed parts of recently modified files. You can learn more about these improvements here.