ReSharper 2016.1 Help

Predefined Live Templates for C++

ReSharper | Templates Explorer | Live Templates | C++

This topic lists all predefined live templates for C++ in ReSharper 2016.1.1. For more information about live templates, see Creating Source Code Using Live Templates

TemplateDetails
ctx

Current file context

Scope everywhere

Body

$CTX$

Parameters

  • CTX - Provides list of items describing current context. This includes file name, containing type name, namespace name, etc. (context)
nguid

Insert new GUID

Scope everywhere

Body

$GUID$

Parameters

  • GUID - Generates new Globally Unique Identifier (GUID) (guid)
unn

Code snippet for new union declaration

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

Body

union $NAME$ {$END$};

Parameters

  • NAME - Evaluates to the specified constant value. (constant)
  • END - The caret position after the template is applied.
wcout

Code snippet for writing to standard output stream

Scope C++ statements

Body

std::wcout << $END$;

Parameters

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

Code snippet for writing to standard log stream

Scope C++ statements

Body

std::wclog << $END$;

Parameters

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

Code snippet for reading from standard input stream

Scope C++ statements

Body

std::wcin >> $END$;

Parameters

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

Code snippet for default constructor declaration with body

Scope C++ type-member declarations

Body

$CLASSNAME$(){$END$}

Parameters

  • CLASSNAME - Evaluates to short name of the most inner containing type. [C++] (cppContainingTypeName)
  • END - The caret position after the template is applied.
vdtor

Code snippet for virtual destructor declaration with body

Scope C++ type-member declarations

Body

virtual ~$CLASSNAME$(){$END$}

Parameters

  • CLASSNAME - Evaluates to short name of the most inner containing type. [C++] (cppContainingTypeName)
  • END - The caret position after the template is applied.
dtor

Code snippet for destructor declaration with body

Scope C++ type-member declarations

Body

~$CLASSNAME$(){$END$}

Parameters

  • CLASSNAME - Evaluates to short name of the most inner containing type. [C++] (cppContainingTypeName)
  • END - The caret position after the template is applied.
enumclass

Code snippet for new enum class declaration

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

Body

enum class $NAME$ {$END$};

Parameters

  • NAME - Evaluates to the specified constant value. (constant)
  • END - The caret position after the template is applied.
clog

Code snippet for writing to standard log stream

Scope C++ statements

Body

std::clog << $END$;

Parameters

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

Code snippet for writing to standard error stream

Scope C++ statements

Body

std::wcerr << $END$;

Parameters

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

Code snippet for writing to standard error stream

Scope C++ statements

Body

std::cerr << $END$;

Parameters

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

Code snippet for reading from standard input stream

Scope C++ statements

Body

std::cin >> $END$;

Parameters

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

Code snippet for new class declaration

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

Body

class $NAME$ {public:$END$};

Parameters

  • NAME - Evaluates to the specified constant value. (constant)
  • END - The caret position after the template is applied.
cout

Code snippet for writing to standard output stream

Scope C++ statements

Body

std::cout << $END$;

Parameters

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

Code snippet for do-while loop

Scope C++ statements

Body

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

Parameters

  • EXPR - Evaluates to the specified constant value. (constant)
  • END - The caret position after the template is applied.
else

Code snippet for 'else' statement

Scope C++ statements

Body

else {$END$}

Parameters

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

Code snippet for new enum declaration

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

Body

enum $NAME$ {$END$};

Parameters

  • NAME - Evaluates to the specified constant value. (constant)
  • END - The caret position after the template is applied.
foreach

Code snippet for 'range-based for' loop

Scope C++ statements

Body

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

Parameters

  • COLLECTION - Show smart code completion list at the point where the variable is evaluated (completeSmart)
  • TYPE - Suggest type for a new variable declared in the template (suggestVariableType)
  • VARIABLE - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
  • END - The caret position after the template is applied.
fori

Code snippet for common 'for' loop pattern with integer index

Scope C++ statements

Body

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

Parameters

  • INDEX - Suggests non-used name which can be used for an index variable at the evaluation point. (suggestIndexVariable)
  • UPPER - no macro
  • END - The caret position after the template is applied.
forr

Code snippet for common 'for' loop pattern with integer index and reversed iteration order

Scope C++ statements

Body

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

Parameters

  • INDEX - Suggests non-used name which can be used for an index variable at the evaluation point. (suggestIndexVariable)
  • MAX - no macro
  • END - The caret position after the template is applied.
if

Code snippet for 'if' statement

Scope C++ statements

Body

if ($EXPR$) { $END$ }

Parameters

  • EXPR - Evaluates to the specified constant value. (constant)
  • END - The caret position after the template is applied.
incg

Code snippet for include guard

Scope C++

Body

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

Parameters

  • FILENAME - Evaluates current file name without extension with all non-alphanumeric replaced with underscores (getAlphaNumericFileNameWithoutExtension)
  • END - The caret position after the template is applied.
main

Code snippet for main declaration

Scope C++ top-level declarations

Body

int main(int argc, char *argv[]) { $END$ }

Parameters

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

Code snippet for namespace decalration

Scope C++ top-level declarations, C++ namespace declarations

Body

namespace $NAME$ {$END$}

Parameters

  • NAME - Evaluates to the specified constant value. (constant)
  • END - The caret position after the template is applied.
str

Code snippet for new struct declaration

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

Body

struct $NAME$ {$END$};

Parameters

  • NAME - Evaluates to the specified constant value. (constant)
  • END - The caret position after the template is applied.
switch

Code snippet for switch statement

Scope C++ statements

Body

switch ($EXPRESSION$) {$END$}

Parameters

  • EXPRESSION - Suggests variables of the specified type. (variableOfType)
  • END - The caret position after the template is applied.
try

Code snippet for try catch

Scope C++ statements

Body

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

Parameters

  • EXCEPTION - Evaluates to the specified constant value. (constant)
  • END - The caret position after the template is applied.
while

Code snippet for 'while' statement

Scope C++ statements

Body

while ($EXPR$) { $END$ }

Parameters

  • EXPR - Evaluates to the specified constant value. (constant)
  • END - The caret position after the template is applied.
Last modified: 19 August 2016