~/talk

C++ Coroutines Demystified

Talkat ACCU 2025 · 2025-04-01..04-04· [c-and-cpp]
slides:none on file

Starts from blank code and walks to a working coroutine by letting the compiler drive each step: use Compiler Explorer with GCC and Clang, add #include <coroutine>, create a Task return type with nested promise_type, implement ~8 promise methods (get_return_object, initial_suspend, final_suspend, unhandled_exception, return_value, yield_value), pass a coroutine_handle into the Task, log execution to see suspension/resume, and finally swap to C++23 std::generator (Fibonacci demo) using std::suspend_always/std::suspend_never so the examples compile and actually run.

AI-written summary · about

  1. 0:00C++ coroutines introduction
  2. 5:43Minimal coroutine in Compiler Explorer
  3. 19:34Coroutine execution and suspension
  4. 34:36Coroutine frames and promise types
  5. 45:11Coroutine lifetime handles
  6. 59:53Returning values from coroutines
  7. 1:01:21Generating sequences with co_yield
  8. 1:13:22C++23 generators
  9. 1:20:17Awaiters and awaitables
  10. 1:29:55Summary
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.