JetBrains Rider 2023.2 Help

Code Templates in C++

All JetBrains Rider's code template features are also supported in C++. You can find the detailed information on these features in the corresponding topics of the .NET-specific templates section.

Live Templates

Live/Surround templates can be used for generating code in existing files and (if there is the $SELECTION$ parameter in the template body) for surrounding code fragments with template code, such as try...catch statement.

Each live template is identified by a Shortcut — a short string of characters, for example foreach — that you can type right in the editor to invoke the template.

JetBrains Rider provides plenty of predefined live templates. You can also create custom live templates on the Editor | Live Templates | C++ page of JetBrains Rider settings Control+Alt+S.

File Templates

File templates are used to create one or more new files with predefined code, such as a type declaration, unit test, and so on. File templates have no shortcuts, they are identified by their descriptions. For more information, refer to Create files from templates .

There are predefined templates for class, struct, source file and header file. You can also create new file.

JetBrains Rider C++: File Templates

Postfix Templates

Postfix templates help you transform expressions that you have already typed without jumping backwards — just type a dot after an expression and pick a template from the completion list.

Below is the list of postfix templates available in C++.





Produces iterators from range

sort(range.begin(), range.end())


Surrounds expression with UE cast



Produces iterators from range

is_sorted(range.cbegin(), range.cend())


Passes expression as argument to co_await

co_await expr


Returns expression from current coroutine

co_return expr;


Passes expression as argument to co_yield

co_yield expr


Surrounds expression with const_cast

const_cast<SomeType &>(expr)


Iterating until boolean expression becomes 'false'

do { } while (expr);


Surrounds expression with dynamic_cast

dynamic_cast<SomeType &>(expr)


Checks boolean expression to be 'false'

if (!expr)


Iterates over range

for (auto && x : range)


Forwards function parameter



Checks boolean expression to be 'true'

if (expr)


Constructs an object and wraps it in a std::shared_ptr



Constructs an object and wraps it in a std::unique_ptr



Produces instantiation expression for type

new SomeType()


Surrounds expression with reinterpret_cast

reinterpret_cast<SomeType &>(expr)


Returns expression from current function

return expr;


Surrounds expression with safe_cast (C++/CLI)



Surrounds expression with static_cast



Produces switch over integral/enum type

switch (expr)


Introduces variable for expression

auto x = expr;


Iterating while boolean expression is 'true'

while (expr)

Last modified: 21 January 2022