Inlay Hints in C++
Last modified: 21 January 2022Parameter name hints
Parameter name hints are editor adornments that show parameter names next to the corresponding arguments at method calls. They can help you find your way through long (and sometimes nested) lists of parameters in function calls and aggregate initialization.
In the example below, parameter name hints help to spot the fact that height and width arguments are mixed up:

Parameter name hints show the names of the members you are initializing and help disentangle complex aggregate initializations in C++17 and later:

tip
The braces around the nested initializer lists may be elided. To make code more readable in this case, you can press Alt+Enter and use the
missing-braces
Clang diagnostic to add braces around the initialization of subobjects.
Parameter name hints are available in dependent code as well:

Namespace name hints
Namespace name hints at the end of namespace definitions could be helpful if you are not following the LLVM or Google guidelines, which suggest adding namespace in a comment after the namespace closing bracket:

tip
You can enable a Clang-Tidy inspection (
llvm-namespace-comment
on the the Code Inspection | Inspection Severity page of ReSharper options (Alt+R, O)) and press Alt+Enter at the end of a namespace definition to use a Clang-Tidy fix generating a closing namespace comment.
Preprocessor directive hints
Preprocessor directive hints help you quickly understand how conditional inclusions (#ifdef
, #ifndef
, #if
, #endif
, #else
, and #elif
) correspond to macro definitions:

Type name hints
Type name hints help you when a type is deduced automatically by the compiler from the surrounding code. ReSharper provides type name hints for auto variables, function and lambda return types, in structured bindings, dependent code, and after function calls.
tip
If you want to quickly disable or configure hints, right-click a hint to open the context menu. From the same menu, you can go to the options page or navigate to the related declaration.
Auto variables
This kind of hints is available for variables with automatically deduced type, which use the auto
or decltype(auto)
type specifiers. By default, the hint will be hidden if the deduced type is clear from the initializer expression, for example when the initializer is a constructor call, a constant, or an explicit cast.

Function and lambda return types
The return types of functions and lambdas can be automatically deduced from the return statement when they are omitted in the code:

Structured bindings
In C++17’s structured binding declarations, type hints are especially useful since the type of a structured binding cannot be explicitly specified.

Dependent code
Type hints also work for dependent code but note that they can affect the performance. In this case, disable the dependent code hints on the Environment | Inlay Hints | C++ | Type Name Hints page of ReSharper options (Alt+R, O).

Function calls
With the default settings, this kind of type hint is shown only after multiline chained member functions calls.

Type conversion hints
Type conversion hints help make hidden implicit conversions visible, so that you are aware of potential performance and correctness implications.
ReSharper 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.

There are granular configuration options for the hints.