Early Access Program

ReSharper C++ Starts 2021.3 EAP

Hello and welcome to ReSharper C++’s final Early Access Program of 2021!

Over the next couple of months, we are going to bring you news about the new features being worked on for the upcoming 2021.3 release. If you’re not familiar with our Early Access Program (EAP), we roll out new free-to-use preview builds every week. We encourage you to join the EAP and share your thoughts on the latest improvements and functionality so that we can make the final release of ReSharper C++ even better.
ReSharper C++ 2021.3 EAP

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


Here are some of the highlights of the first EAP build:

Visual Studio 2022

In case you missed the announcement, Visual Studio 2022 will be a 64-bit application. Moving to a 64-bit process means that devenv.exe will no longer be limited to 4GB of memory, which is going to reduce the memory pressure and improve the overall performance and responsiveness of large solutions.

This EAP build includes initial support for Visual Studio 2022 Preview. If you’ve experienced performance issues in the past, we encourage you to check out this build in Visual Studio 2022 Preview! Please let us know if you encounter any issues with this early preview.

С++20 modernizing inspections

In ReSharper C++ 2021.3, we are continuing to work on supporting the latest C++ language standard. This EAP build brings a number of code inspections that will help you to adopt the new standard library features.

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

Before C++20, the way you remove elements with a specific value or that satisfy a given predicate from a container was dependent on the type of the container. The new standard brings convenient library functions for erasing elements from any STL container – std::erase and std::erase_if (P1209). A dedicated inspection will tell you if the old erase-remove idiom can be replaced with modern std::erase or std::erase_if:
'std::erase'/'std::erase_if' can be used instead of the remove-erased idiom

Another new library addition is the smart pointer creation functions that perform default initialization (P1973). The C++11 helpers make_shared and make_unique always construct the object contained in the smart pointer using value initialization. But in some scenarios value initialization performs redundant work and can hurt performance, like when you need to allocate an array of built-in types and immediately initialize it afterwards. In cases like these you can now use make_shared_for_overwrite or make_unique_for_overwrite instead, which perform default initialization:
Constructor of smart pointer is used instead of its make function

Code analysis

We’re constantly adding new inspections to ReSharper C++ to help you improve the quality of your code. Let’s take a quick look at some of the new analyses available in this EAP build.

Elaborated type specifiers were inherited by C++ from the C language. However, in idiomatic C++ code, they should be used either to declare a new class or to refer to a previously declared struct hidden by a more local non-type declaration. If neither of these cases is true, ReSharper C++ will now suggest removing the redundant elaborated type specifier.
Redundant elaborated type specifier

A new inspection finds for loops that can be written in a more concise way as a while loop. The accompanying quick-fix lets you quickly perform this rewrite.
For-loop can be replaced with while-loop

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.
Namespace definition containing single class specialization

An object of an exception type should usually be created only if you intend to throw it. If you construct such an object but do not use it, ReSharper C++ now warns you and lets you quickly add the throw keyword.
May be missing keyword throw

Finally, ReSharper C++ will notify you if the [[nodiscard]] attribute is applied to a function without a return value.
[[nodiscard]] cannot be applied to functions without a return value

Evaluation result in Quick Info

ReSharper C++ 2021.3 updates the Quick Info tooltip to include the evaluation result for constant expressions. Let’s take a look at some examples where this feature can help you with your day-to-day tasks.

If there’s an expression that can be evaluated during compile-time under the mouse cursor (or under the caret if you invoke Quick Info with the Ctrl+K, Ctrl+I shortcut), ReSharper will attempt to evaluate it and append the result to the tooltip.
Evaluation of Cyclic redundancy check

You can now consult the message about a failing static_assert to see what the assertion expression evaluates to:
Details about failing static_assert

Want to check out the value of a sizeof or alignof operator? Just hover the mouse over it:
Evaluation of sizeof

As a rule, ReSharper C++ tries to evaluate the innermost expression. For example, if you have a binary expression, you can hover over each operand to get a tooltip with its value, or the operator to get a tooltip with the final result:
Evaluation result in Quick Info

We’ve also improved the evaluation engine to support constexpr virtual functions. Since C++20, virtual function calls can be used in constant expressions (P1064), which makes it easier to share code between compile-time and runtime.
С++20 constexpr virtual

Go to Declaration receives a couple of enhancements:

  • You can now navigate from a goto statement to the corresponding label.
    Navigate from a goto statement to the corresponding label
  • Navigation was previously unavailable in inactive preprocessor blocks. ReSharper C++ 2021.3 offers heuristic declaration search in inactive code:
    Navigation in inactive preprocessor blocks

The File Structure window now groups symbols with qualified names that have the same qualifier. This is especially useful in .cpp files that contain a lot of out-of-class functions:
Out-of-class functions in File Structure

In our roadmap, we also promised to focus more on product quality for the 2021.3 release cycle. We’ve already resolved over 150 issues in our issue tracker. The list of important bugs fixed in the first EAP build includes:

  • ReSharper C++ now works correctly with the Unreal Engine Sparse Class Data system.
  • Fixed an issue in Unreal Engine solutions with background indexing enabled where caches sometimes were not saved.
  • Rename refactoring can now handle macro arguments that are used several times in the macro expansion.

These are the highlights of the first EAP build! Please report any issues you encounter to our issue tracker or the support forum.


Your ReSharper C++ team
The Drive to Develop