Coroutine Concepts co_await co_yield co_return
Learn the three coroutine keywords and how the compiler transforms them.
What are Coroutines?
A coroutine is a function that can suspend and later resume. Useful for asynchronous code, generators, and cooperative multitasking.
The Three Keywords
C++20 introduces three new keywords for coroutines:
co_await— suspend until an awaitable completesco_yield— suspend and yield a valueco_return— finish the coroutine, optionally with a value
All lessons in this course
- Coroutine Concepts co_await co_yield co_return
- Implementing a Simple Generator
- Async Tasks and Awaiter Types
- Coroutine Frame Allocation