C++ Coroutines - Gods from the Machine

Phil Nash

⏱ 90 minute session
intermediate
advanced
11:00-12:30, Wednesday, 2nd April 2025
Coroutines seem to work like magic - with the compiler generating a lot of machinery for you. Yet, at the same time, writing them from scratch remains complex with lots of moving parts! Trying to keep them all in your head while learning it is what makes coroutines so hard to master.

But the dance between all those parts and what the compiler does for you is so tight that you can literally let your compiler be your guide. I'll show how, from a standing start, you can get from no code to a working, useful, coroutine while only needing to know a handful of extra pieces of information.

In ancient Greek theatre puzzling plots were often resolved by external factors - often an actor or prop lowered in from a crane (in Greek, "mēkhanês", or Latin: "mechine"). This came to be called, "deus ex machina" - gods from the machine. We will keep our deus ex machina to a minimum and leave the compiler to teach us the rest.

Finally! Coroutines without the suspense!

🏷 C++20
🏷 Coroutines

Phil Nash

Phil is the original author of the C++ test framework, Catch2 and is an independent consultant and trainer, specialising in TDD and Modern C++.

Formerly Developer Advocate at Sonar and JetBrains he has had a career that spans finance, mobile and software security.

He's also a member of the ISO C++ standards committee, organiser of C++ London and C++ on Sea, as well as co-host and producer of CppCast.