Explain how C++20 Coroutines work at a high level (Promises, Awaitables).
Last updated
The promise type (found from the return type) defines lifecycle and result via hooks like
get_return_object(),initial_suspend(), andfinal_suspend().The coroutine frame stores parameters, locals, and the promise. A
std::coroutine_handlecanresume()ordestroy()it.co_awaitdrives an awaitable throughawait_ready(),await_suspend(), andawait_resume().co_yield vis sugar forco_await promise.yield_value(v).