~/talk

Understanding C++ Coroutines by Example: Generators (Part 1 of 2)

Talkat CppCon 2022 · 2022-09-11..09-16· [javascript]
links:none on file
slides:none on file

Step‑by‑step construction of a working C++20 generator: compiler transformation into a frame with promise_type, how yield_value and return_void map to suspension points, and why initial_suspend and final suspend matter for exceptions and lifetime. Implements a generator type with a coroutine_handle, call operator, advance/get_value iterator style, shows copy vs pointer storage for yielded values, prints "hello world" and an infinite Fibonacci example, points out inefficiencies and recommends cppcoro/folly or the forthcoming std::generator.

AI-written summary · about

  1. 0:00C++ coroutines intro
  2. 2:18What coroutines are
  3. 5:08Coroutine suspension
  4. 9:56Lazy async best practices
  5. 13:52Initial suspension need
  6. 16:41Safe coroutine destroy
  7. 18:47Params to coroutines
  8. 20:33Generator type design
  9. 22:20Promise type functions
  10. 29:54Exceptions in coroutines
  11. 33:10Coroutines vs state machines
  12. 42:17Basic generator drawbacks
  13. 44:30Coroutines vs futures
  14. 45:54Extra generator calls
  15. 47:41Yielded value lifetime
  16. 51:20Has-value checks
  17. 53:30Avoid value copying
  18. 57:18Refining generator interface
  19. 59:44Iterator interface for generators
~/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.