ReSharper 2016.1 Help

Predefined Surround Templates for C++

ReSharper | Templates Explorer | Surround Templates | C++

This topic lists all predefined surround templates for C++ in ReSharper 2016.1.1. For more information about surround templates, see Surrounding Code Fragments with Templates

TemplateDetails
()

Surround the selection with parentheses

Scope C++ expressions, C# 2.0+ expressions

Body

($SELECTION$$END$)

Parameters

  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.
{}

Surround the selection with braces

Scope C++ statements, C# 2.0+

Body

{ $SELECTION$$END$ }

Parameters

  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.
static_cast

Surround the selected expression with static_cast

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.
struct

Surround selected declarations with struct

Scope C++ type-member declarations, C++ class declarations

Body

struct $NAME$ { $SELECTION$ };

Parameters

  • NAME - no macro
  • SELECTION - The text selected by the user before invoking the template.
dynamic_cast

Surround the selected expression with dynamic_cast

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

Add a namespace to the selected code

Scope C++ namespace declarations, C++ top-level 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

Scope C++

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.
if

Put the selection into an if statement block

Scope C++ statements

Body

if ($END$) { $SELECTION$ }

Parameters

  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.
const_cast

Surround the selected expression with const_cast

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

Surround the selected expression with reinterpret_cast

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.
while

Put the selection into a while loop

Scope C++ statements

Body

while ($END$) { $SELECTION$ }

Parameters

  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.
for

Put the selection into a for loop

Scope C++ statements

Body

for ($END$) { $SELECTION$ }

Parameters

  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.
do...while

Put the selection into a do..while loop

Scope C++ statements

Body

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

Parameters

  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.
try...catch

Put the selection into the try block of the try..catch statement

Scope C++ statements

Body

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

Parameters

  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.
cast

Cast the selection to a specific type

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 ...

Scope C++ namespace declarations, C++ top-level 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.
class

Add a class to the selected code

Scope C++ class declarations, C++ type-member declarations

Body

class $NAME$ { $SELECTION$ };

Parameters

  • NAME - no macro
  • SELECTION - The text selected by the user before invoking the template.
incg

Surround selection with an include guard

Scope C++

Body

#ifndef $FILENAME$_H #define $FILENAME$_H $SELECTION$ #endif // $FILENAME$_H

Parameters

  • FILENAME - Evaluates current file name without extension (getFileNameWithoutExtension)
  • DATE - Evaluates file creation date and time (getCreationTime)
  • SELECTION - The text selected by the user before invoking the template.
if...else

Put the selection into an if statement block and add an else block

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: 19 August 2016