ReSharper 10.0 Help

Predefined Surround Templates for C++

ReSharper | Tools | Templates Explorer | Surround Templates | C++

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

TemplateDetails
{}

Surround the selection with braces

Scope C# 2.0+, C++ statements

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 parentheses

Scope C# 2.0+ expressions, C++ 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.
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.
anonymous namespace

anonymous namespace

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

Add a namespace to the selected code

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: 8 January 2016