Search⌘ K
AI Features

Coroutine Types in the Coroutines Library

Discover the different coroutine types provided by the cppcoro library as an implementation example for C++20 coroutines. Learn how tasks represent asynchronous computations executed lazily and how generators produce sequences of values efficiently. This lesson includes practical examples showing coroutine workflows and asynchronous execution patterns to deepen your understanding of coroutines in modern C++ programming.

We'll cover the following...

The coroutines library, the modularized standard library, and the executors have something in common: they are supposed to be part of C++23.

Coroutines in C++20 are not more than a framework for the implementation of concrete coroutines. This means that it is up to the software developer to implement coroutines. The cppcoro library from Lewis Baker gives the first idea how a library of coroutines could look like. His library provides high-level coroutines, which C++20 does not offer.

🔑 Using cppcoro

The cppcoro library is based on the coroutines TS. The TS stands for technical specification and is the preliminary version of the coroutines functionality we get with C++20. Lewis will presumably port the cppcoro library from the coroutines TS to the coroutines defined in C++20. The library can be used on Windows (Visual Studio 2017) or Linux (Clang 5.0/6.0 and libc++). For my ...