ReSharper 2017.2 Help

Predefined Live Templates for C++

ReSharper | Templates Explorer | Live Templates | C++

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

TemplateDetails
myDoc

Scope C++

Body

/** * \brief $END$ * \tparam $TNAME$ $TDESCRIPTION$ * \param $PNAME$ $PDESCRIPTION$ * \param $MNAME$ $MDESCRIPTION$ * \return $RETURN$ */

Parameters

  • TNAME - Duplicates the containing template line for each template parameter and evaluates to the template parameter name (cppTemplateParameterName)
  • TDESCRIPTION - no macro
  • PNAME - Duplicates the containing template line for each function parameter and evaluates to the parameter type (cppFunctionParameterType)
  • PDESCRIPTION - no macro
  • MNAME - no macro
  • MDESCRIPTION - no macro
  • RETURN - Evaluates to the function return type (cppFunctionReturnType)
  • END - The caret position after the template is applied.
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. (typeName)
  • 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. (typeName)
  • 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. (typeName)
  • 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.
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$) { $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.
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.
doc

Documentation template

Scope C++ comments

Body

/** * \brief $END$ * \tparam $TNAME$ $TDESCRIPTION$ * \param $PNAME$ $PDESCRIPTION$ * \param $MNAME$ $MDESCRIPTION$ * \return $RETURN$ */

Parameters

  • TNAME - Duplicates the containing template line for each template parameter and evaluates to the template parameter name (cppTemplateParameterName)
  • TDESCRIPTION - Evaluates to the specified constant value. (constant)
  • PNAME - Duplicates the containing template line for each function parameter and evaluates to the parameter name (cppFunctionParameterName)
  • PDESCRIPTION - Evaluates to the specified constant value. (constant)
  • MNAME - Duplicates the containing template line for each macro parameter and evaluates to the macro parameter name (cppMacroParameterName)
  • MDESCRIPTION - Evaluates to the specified constant value. (constant)
  • RETURN - Keeps the containing template line only if the function return type is non-void (cppFunctionReturnValue)
  • END - The caret position after the template is applied.
This template is expanded when you invoke the Document context action on a type or type member.
foreach

Code snippet for 'range-based for' loop

Scope C++ statements

Body

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

Parameters

  • COLLECTION - Show basic code completion list at the point where the variable is evaluated (complete)
  • TYPE - Show smart code completion list at the point where the variable is evaluated (completeSmart)
  • VARIABLE - When exectuted 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.
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 { $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.
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.
fori

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

Scope C++ statements

Body

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

Parameters

  • INDEX - Suggests non-used name which can be used for an index variable at the evaluation point. (suggestIndexVariable)
  • UPPER - no macro
  • SELECTION - The text selected by the user before invoking the template.
  • END - The caret position after the template is applied.
if

Code snippet for '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.
incg

Code snippet for include guard

Scope C++

Body

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

Parameters

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 { $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

Code snippet for '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.
Last modified: 20 October 2017