Conference | Live Schedule | Talks | Get your ticket | Slides | Set your timezone
Using std::generator<> in Practice

Nicolai Josuttis
On Day 1 at 17:15 (CET/Berlin) in Track B [Opal Room and online]
C++20 introduced coroutines, which are functions that can be subspended and later resumed (in the same or a different context). As a consequence, coroutines allow programs to switch back and forth between different paths of execution. However, C++20 only provided low-level support, which is highly flexible but requires a lot of boilerplate code to implement even simple coroutine use cases.
One key element of this boilerplate code are coroutine interfaces, which
- serve as standard customization point for the compiler
to configure general aspects of the coroutine and - define the API to deal with the coroutine.
With std::generator<>, C++23 introduces a first standard coroutine interface for the use cases, where a coroutine generates a sequence of values, which the user(s) of the coroutine can process using a range interface.
This talks introduces the std::generator<> class template, explains how it can be used in practice, provides practical insights about special attributes, and discusses various pitfalls you shouldhave in mind when using coroutines and std::generator<>.
Please login to comment