JetBrains Rider 2021.1 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 Ctrl+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. See Create Files from Templates for details.

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

ShortcutDescriptionExample
.beg..endProduces iterators from rangesort(range.begin(), range.end())
.CastSurrounds expression with UE castCast<SomeType>(expr)
.cbeg..cendProduces iterators from rangeis_sorted(range.cbegin(), range.cend())
.co_awaitPasses expression as argument to co_awaitco_await expr
.co_returnReturns expression from current coroutineco_return expr;
.co_yieldPasses expression as argument to co_yieldco_yield expr
.const_castSurrounds expression with const_castconst_cast<SomeType &>(expr)
.doIterating until boolean expression becomes 'false'do { } while (expr);
.dynamic_castSurrounds expression with dynamic_castdynamic_cast<SomeType &>(expr)
.elseChecks boolean expression to be 'false'if (!expr)
.foreachIterates over rangefor (auto && x : range)
.forwardForwards function parameterstd::forward<Arg>(arg)
.ifChecks boolean expression to be 'true'if (expr)
.make_sharedConstructs an object and wraps it in a std::shared_ptrstd::make_shared<SomeType>()
.make_uniqueConstructs an object and wraps it in a std::unique_ptrstd::make_unique<SomeType>()
.newProduces instantiation expression for typenew SomeType()
.reinterpret_castSurrounds expression with reinterpret_castreinterpret_cast<SomeType &>(expr)
.returnReturns expression from current functionreturn expr;
.safe_castSurrounds expression with safe_cast (C++/CLI)safe_cast<SomeType>(expr)
.static_castSurrounds expression with static_caststatic_cast<SomeType>(expr)
.switchProduces switch over integral/enum typeswitch (expr)
.varIntroduces variable for expressionauto x = expr;
.whileIterating while boolean expression is 'true'while (expr)
Last modified: 08 March 2021