ReSharper 2023.1 Help

Predefined Live Templates for C++

This topic lists all predefined live templates for C++ in ReSharper 2023.1. 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 a list of items describing current context. This includes file name, containing type name, namespace name, etc.

nguid

Insert new GUID

Scope Everywhere

Body

$GUID$

Parameters

  • GUID - Generates a new Globally Unique Identifier (GUID)

union

union declaration

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

Body

union $NAME$ {$END$};

Parameters

  • NAME - Evaluates to the specified constant value

  • 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 the short name of the most inner containing type

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

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

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

UINTERFACE

UINTERFACE declaration

Scope Unreal Engine solutions, C++ class declarations

Body

UINTERFACE() class U$NAME$:public UInterface {GENERATED_BODY()}; class I$NAME$ {GENERATED_BODY() public:$END$};

Parameters

  • NAME - Evaluates to the specified constant value

  • 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 the short name of the most inner containing type

  • 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

  • BASE - Shows basic code completion list at the point where the variable is evaluated

  • 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

  • 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

  • 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 the short name of the most inner containing type

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

  • 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 the short name of the most inner containing type

  • 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

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

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

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

  • 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 the short name of the most inner containing type

  • 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

  • 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 a unique name for an index variable at the evaluation point

  • 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

  • TDESCRIPTION - Evaluates to the specified constant value

  • PNAME - Duplicates the containing template line for each function parameter and evaluates to the parameter name

  • PDESCRIPTION - Evaluates to the specified constant value

  • MNAME - Duplicates the containing template line for each macro parameter and evaluates to the macro parameter name

  • MDESCRIPTION - Evaluates to the specified constant value

  • RETURN - Keeps the containing template line only if the function return type is non-void

  • 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

  • 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

  • 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

  • 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 a visible variable that can be enumerated (that is, used in a foreach loop as collection)

  • TYPE - Suggests a type for a new variable declared in the template

  • VARIABLE - When executed in a variable declaration (where variable name should stand), suggests a name for the variable

  • 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 a unique name for an index variable at the evaluation point

  • 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

  • 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 to the current file name in uppercase with all non-alphanumeric characters replaced with underscores

  • 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

  • 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

  • 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

  • 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

  • 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

  • SELECTION - The text selected by the user before invoking the template.

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

Last modified: 27 March 2023