ReSharper 2021.3 Help

Predefined Live Templates for C++

ReSharper | Templates Explorer | Live Templates | C++

This topic lists all predefined live templates for C++ in ReSharper 2021.3. For more information about live templates, see Create 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)

union

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.

UCLASS

UCLASS declaration

Scope Unreal Engine solutions, C++ class declarations

Body

UCLASS() class $NAME$:public $BASE$ {GENERATED_BODY() public:$END$};

Parameters

  • NAME - Evaluates to the specified constant value. (constant)

  • BASE - Show basic code completion list at the point where the variable is evaluated (complete)

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

UENUMCLASS

UENUM declaration using the "enum class" syntax

Scope Unreal Engine solutions, C++ class declarations

Body

UENUM() enum class $NAME$ {$END$};

Parameters

  • NAME - Evaluates to the specified constant value. (constant)

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

UENUM

UENUM declaration

Scope Unreal Engine solutions, C++ class declarations

Body

UENUM() enum $NAME$ {$END$};

Parameters

  • NAME - Evaluates to the specified constant value. (constant)

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

else

else statement

Scope C++ statements

Body

else { $END$ }

Parameters

  • 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

Function 'to_string' for enum

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.

USTRUCT

USTRUCT declaration

Scope Unreal Engine solutions, C++ class declarations

Body

USTRUCT() struct $NAME$ {GENERATED_BODY() $END$};

Parameters

  • NAME - Evaluates to the specified constant value. (constant)

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

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.

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.

class

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.

enum

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

range-based for loop

Scope C++ statements

Body

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

Parameters

  • COLLECTION - Suggests visible variable that can be enumerated (that is, used in foreach loop as collection) (enumerableVariable)

  • TYPE - Suggest type for a new variable declared in the template (suggestVariableType)

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

fori

for loop pattern with integer index

Scope C++ statements

Body

for (int $INDEX$ = 0; $INDEX$ < $MAX$; ++$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.

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, at line start

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.

namespace

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.

struct

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

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

try catch statement

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: 07 April 2022