Early Access Program News

CLion 2021.1 EAP: Postfix Completion for C and C++

A new CLion 2021.1 EAP build (211.6085.16) is now available from our website, via the Toolbox App, or as a snap package (if you are using Ubuntu). Note that if you are on macOS, there is a separate build for Apple Silicon (M1 chip).


Today we are delighted to introduce postfix completion for C++ in CLion! Read on for more details.

Postfix completion for C++

Postfix code completion lets you add code around an expression you’ve just typed. It can wrap an expression with a frequently used language construct, or pass the expression as the first argument of a free function.

Postfix completion

Postfix templates to wrap expressions with language constructs

Postfix templates can help you with typical language constructs. Here’s how you can use them:

  1. Type an expression and then a dot.
  2. After the dot, type the template abbreviation (postfix).
  3. Press the expansion key (it’s Tab by default, but can be reconfigured in Settings/Preferences | Editor | General | Postfix Completion). Alternatively, simply select the abbreviation you need from the completion list that appears at step 2.
  4. The template expands and wraps your expression.

Postfix for template

This is really useful especially when it comes to wrapping with a C++-style cast, make_shared/make_unique, various loops, begin/end idioms, and more:

Postfix forward template

The CLion 2021.1 EAP3 build ships with 20+ predefined templates, but unfortunately, you cannot define your own templates – for now. To find the list of abbreviations and the explanations of what the templates expand into, please go to Settings/Preferences | Editor | General | Postfix Completion. You can also enable or disable any templates from this list:

Postfix templates settings

Postfix completion to pass the expression as the first argument of a free function

In this scenario, you can use postfix code completion to pass the expression you’ve just typed as the first argument to a free function. Here’s how you can use it:

  1. Type an expression and then type a dot.
  2. CLion will suggest free functions that would accept the expression as the first parameter (taking ADL into account).
  3. After you select a function, the code is updated so that the expression is passed as the first argument.

Postfix free function

Do you think this postfix code completion can speed up your coding? What other postfix templates would you like to see in CLion? Let us know in the comments below!

Known issues are linked to this ticket CPP-4039. Feel free to submit a new report if you find any other problems.

This isn’t the first build in our current EAP. Here is a short summary of the enhancements that have already been introduced in earlier 2021.1 EAP builds:

  • Global Data Flow Analysis
  • Google Sanitizers, Valgrind Memcheck, Code Coverage in remote mode
  • Clazy analyzer in CLion
  • Improvements to Makefile and CMake projects

This may also be a good time to mention Code With Me – our new service for remote collaborative development, which has recently added support for voice and video calls and is now in Beta. Learn more about Code With Me.

The full release notes are available here.


Your CLion team
The Drive to Develop

image description