Lightning Talk: Implementing Coroutines Using C++17
summary
An implementation reproduces coroutines on C++17 using macros, template metaprogramming, and assembly, a surprisingly compact ~200 lines with a test that still runs. Resume is implemented by an assembly helper that smashes the return address and a noinline builtin-return-address function; empty asm forces register reloads to avoid compiler assumptions. Locals live in generated nested frame structs found by a compile-time counter, with computed alignment/size for storage and explicit cleanup propagation so the coroutine actually suspends, resumes, and destroys correctly.
AI-written summary · about
related talks
06mImplementing coroutines using C++17
58mAn Introduction to C++ Coroutines
01h 00mUsing Coroutines to Implement C++ Exceptions for Freestanding Environments
01h 02mC++20’s Coroutines for Beginners
01h 03mDeciphering C++ Coroutines - A Diagrammatic Coroutine Cheat Sheet
01h 05mCoroutines: C++ vs Rust
53mC++ Coroutines and Structured Concurrency in Practice
55mC++20 coroutines as an API principle
