InfoQ Homepage News C++20 Feature List Now Frozen: Modules, Coroutines, and Concepts are in; Contracts out

C++20 Feature List Now Frozen: Modules, Coroutines, and Concepts are in; Contracts out

Leia em Português

This item in japanese


The ISO C++ Committee has closed the feature list for the next C++ standard, dubbed C++20, scheduled to be published by February 2020. C++20 will be a significant revision of C++, bringing modules, coroutines, and concepts, among its major new features.

At its latest meeting in Cologne, the ISO C++ Committee agreed on the last changes to the C++20 draft before submitting it to all the national standard bodies to gather their feedback. Among the latest additions are std::format, the C++20 Synchronization library, and better threading. Contracts, on the contrary, have fallen out of the draft and have been postponed to C++23/C++26.

C++20 will introduce a new text formatting API, std::format, with the goal of being as flexible as the printf family of functions, with its more natural call style and separation of messages and arguments, and as safe and extensible as iostreams. std::format will make it possible to write:

string message = format("The answer is {}.", 42);

C++20 will also improve synchronization and thread coordination, including support for efficient atomic waiting and semaphores, latches, barriers, lockfree integral types, and more.

In previous meetings, the standard committee had already agreed on the inclusion of a few major features that promise to radically change the way developers use the language, including modules, coroutines, and concepts.

Module support will be orthogonal to namespaces and will enable the structuring of large codebases into logical parts without requiring the separation of header and source files. This is how you can define a simple module exporting a function and its usage in a different file:

// math.cppm
export module mod1;

export int identity(int arg) {
    return arg;

// main.cpp

import mod1;

int main() {

Coroutines are functions that can be stopped and resumed. They are stack-less, meaning they return to the caller when suspended. Coroutines support three new operators: co_await to suspend execution without returning a value to the caller; co_yield to suspend while returning a value; co_return to finalize the execution and return a value. Those three operators enable the creation of asynchronous tasks, generators, and lazy functions. The following is an example of generator:

generator<int> iota(int n = 0) {
    co_yield n++;

Another new major feature in C++20 will be concepts, which provide the foundation for equational reasoning. For example, concepts can be used to perform compile-time validation of template arguments and perform function dispatch based on properties of types.

Besides contracts, C++20 will not include a number of additional major language features that have been deferred to C++23/C++26, including reflection metaclasses, executors, properties, and others.

There is of course a lot more to C++20 that can be covered in a short post, so make sure you read the full trip report for the complete detail.

We need your feedback

How might we improve InfoQ for you

Thank you for being an InfoQ reader.

Each year, we seek feedback from our readers to help us improve InfoQ. Would you mind spending 2 minutes to share your feedback in our short survey? Your feedback will directly help us continually evolve how we support you.

Take the Survey

Rate this Article


Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • Thank god contracts is out

    by Kurt Guntheroth,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Failing a contract caused a program to exit, when programs that need to keep running really wanted it to throw an exception. People need to learn (and I'm talking about the ISO committee now) that the way you terminate a C++ program is by throwing an exception. That way programs can decide not to terminate if terminating is a bad idea, like in a driverless car or a rocket.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p


Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.