ReSharper 2018.3 Help

Predefined Live Templates for C++

ReSharper | Templates Explorer | Live Templates | C++

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

Template

Details

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

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

Write to standard output stream

Scope C++ statements

Body

std::wcout << $END$;

Parameters

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

wclog

Write to standard log stream

Scope C++ statements

Body

std::wclog << $END$;

Parameters

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

cctor

Copy constructor declaration with body

Scope C++ type-member declarations

Body

$CLASSNAME$($CONSTCLASSNAME$ & $NAME$){$END$}

Parameters

  • CLASSNAME - Evaluates to short name of the most inner containing type. (typeName)

  • CONSTCLASSNAME - Evaluates to the short name of the most inner containing type with a const specifier. (constTypeName)

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

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

wcin

Read from standard input stream

Scope C++ statements

Body

std::wcin >> $END$;

Parameters

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

ctor

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.

mctor

Move constructor declaration with body

Scope C++ type-member declarations

Body

$CLASSNAME$($CLASSNAME$ && $NAME$) noexcept {$END$}

Parameters

  • CLASSNAME - Evaluates to short name of the most inner containing type. (typeName)

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

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

vdtor

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.

enum_to_string

Scope C++ namespace declarations

Body

const char * to_string($ENUM$ e) { switch (e) { case $ENUMERATOR$: return $ENUMERATOR_NAME$; default: return "unknown"; } }

Parameters

  • ENUM - The name of the enum that the action is invoked on. (cppEnumToStringEnum)

  • ENUMERATOR - Duplicates the containing template line for each enumerator and evaluates to the name of the enumerator. (cppEnumToStringEnumerator)

  • ENUMERATOR_NAME - Duplicates the containing template line for each enumerator and evaluates to a string with the name of the enumerator. (cppEnumToStringEnumeratorName)

This template is expanded when you invoke the Convert enum to string context action on an enum declaration.

dtor

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

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

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.

clog

Write 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

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

wcerr

Write to standard error stream

Scope C++ statements

Body

std::wcerr << $END$;

Parameters

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

cerr

Write to standard error stream

Scope C++ statements

Body

std::cerr << $END$;

Parameters

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

cin

Read from standard input stream

Scope C++ statements

Body

std::cin >> $END$;

Parameters

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

cls

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

Write to standard output stream

Scope C++ statements

Body

std::cout << $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.

else

'else' statement

Scope C++ statements

Body

else {$END$}

Parameters

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

enm

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

'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

'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

Include guard

Scope C++ top-level declarations

Body

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

Parameters

  • FILENAME - Evaluates current file name in upper case with all non-alphanumeric replaced with underscores (getUpperCaseAlphaNumericFileName)

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

main

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

namespace declaration

Scope 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

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

'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: 13 February 2019