Understanding, Using, and Improving std::generator

Johannes Kalmbach

⏱ 60 minute session
intermediate
advanced
15:30-16:30, Wednesday, 25th June 2025

Generators are one of the most common uses of C++20 coroutines and the only one directly supported in the standard library (since C++23). In this talk, we will explore the interface and potential applications of std::generator, as well as its performance on current compilers.

We will also explain why, in many cases, you should not use std::generator as-is. Instead, we will show how you can customize its behavior by starting with the source code. Key topics include adding an arbitrary payload to generators alongside the yielded values, and using caching techniques to mitigate performance penalties when working with generators.


🏷 coroutines

Johannes Kalmbach

I am a researcher and PhD candidate at the University of Freiburg where I use modern C++ to build a highly efficient RDF/SPARQL engine for knowledge graphs with hundreds of billions of statements. I also teach undergraduate students in C++ and algorithms.