ReSharper 2021.3 Help

Predefined Surround Templates for C++

ReSharper | Templates Explorer | Surround Templates | C++

This topic lists all predefined surround templates for C++ in ReSharper 2021.3. For more information about surround templates, see Surround code fragments with templates

Template

Details

forr

Reversed for

Scope C++ statements

Body

for (int $INDEX$ = $MAX$ - 1; $INDEX$ >= 0 ; --$INDEX$) { $SELECTION$$END$ }

Parameters

  • INDEX - Suggests non-used name which can be used for an index variable at the evaluation point. (suggestIndexVariable)

  • MAX - no macro

  • SELECTION - The text selected by the user before invoking the template.

  • END - The caret position after the template is applied.

wcerr

Write to standard error stream

Scope C++ statements

Body

std::wcerr << $END$;

Parameters

  • END - The caret position after the template is applied.

do

do while loop

Scope C++ statements

Body

do { $SELECTION$$END$ } while ($EXPR$);

Parameters

  • EXPR - Evaluates to the specified constant value. (constant)

  • SELECTION - The text selected by the user before invoking the template.

  • END - The caret position after the template is applied.

foreach

range-based for loop

Scope C++ statements

Body

for ($TYPE$ $VARIABLE$ : $COLLECTION$) { $SELECTION$$END$ }

Parameters

  • COLLECTION - Suggests visible variable that can be enumerated (that is, used in foreach loop as collection) (enumerableVariable)

  • TYPE - Suggest type for a new variable declared in the template (suggestVariableType)

  • VARIABLE - When executed in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)

  • SELECTION - The text selected by the user before invoking the template.

  • END - The caret position after the template is applied.

fori

for loop pattern with integer index

Scope C++ statements

Body

for (int $INDEX$ = 0; $INDEX$ < $MAX$; ++$INDEX$) { $SELECTION$$END$ }

Parameters

  • INDEX - Suggests non-used name which can be used for an index variable at the evaluation point. (suggestIndexVariable)

  • MAX - no macro

  • SELECTION - The text selected by the user before invoking the template.

  • END - The caret position after the template is applied.

if

if statement

Scope C++ statements

Body

if ($EXPR$) { $SELECTION$$END$ }

Parameters

  • EXPR - Evaluates to the specified constant value. (constant)

  • SELECTION - The text selected by the user before invoking the template.

  • END - The caret position after the template is applied.

try

try catch statement

Scope C++ statements

Body

try { $SELECTION$$END$ } catch ($EXCEPTION$) {}

Parameters

  • EXCEPTION - Evaluates to the specified constant value. (constant)

  • SELECTION - The text selected by the user before invoking the template.

  • END - The caret position after the template is applied.

while

while statement

Scope C++ statements

Body

while ($EXPR$) { $SELECTION$$END$ }

Parameters

  • EXPR - Evaluates to the specified constant value. (constant)

  • SELECTION - The text selected by the user before invoking the template.

  • END - The caret position after the template is applied.

static_cast

static_cast expression

Scope C++ expressions

Body

static_cast<$TYPE$>($SELECTION$)

Parameters

  • TYPE - Guess type expected at this point (guessExpectedType)

  • SELECTION - The text selected by the user before invoking the template.

dynamic_cast

dynamic_cast expression

Scope C++ expressions

Body

dynamic_cast<$TYPE$>($SELECTION$)

Parameters

  • TYPE - Guess type expected at this point (guessExpectedType)

  • SELECTION - The text selected by the user before invoking the template.

namespace

Anonymous namespace declaration

Scope C++ namespace declarations

Body

namespace { $SELECTION$$END$ }

Parameters

  • SELECTION - The text selected by the user before invoking the template.

  • END - The caret position after the template is applied.

#if...#endif

Code snippet for #if...#endif preprocessor directive

Scope C++, at line start

Body

#if $END$ $SELECTION$ #endif

Parameters

  • SELECTION - The text selected by the user before invoking the template.

  • END - The caret position after the template is applied.

const_cast

const_cast expression

Scope C++ expressions

Body

const_cast<$TYPE$>($SELECTION$)

Parameters

  • TYPE - Guess type expected at this point (guessExpectedType)

  • SELECTION - The text selected by the user before invoking the template.

reinterpret_cast

reinterpret_cast expression

Scope C++ expressions

Body

reinterpret_cast<$TYPE$>($SELECTION$)

Parameters

  • TYPE - Guess type expected at this point (guessExpectedType)

  • SELECTION - The text selected by the user before invoking the template.

cast

C-like cast expression

Scope C++ expressions

Body

(($TYPE$) $SELECTION$)

Parameters

  • TYPE - Guess type expected at this point (guessExpectedType)

  • SELECTION - The text selected by the user before invoking the template.

namespace ...

namespace declaration

Scope C++ namespace declarations

Body

namespace $NAME$ { $SELECTION$$END$ }

Parameters

  • NAME - Evaluates to the specified constant value. (constant)

  • SELECTION - The text selected by the user before invoking the template.

  • END - The caret position after the template is applied.

if...else

if else statement

Scope C++ statements

Body

if ($COND$) { $SELECTION$ } else { $END$ }

Parameters

  • COND - Suggests variables of the specified type. (variableOfType)

  • SELECTION - The text selected by the user before invoking the template.

  • END - The caret position after the template is applied.

Last modified: 07 April 2022