C++20 introduced minimal support for coroutines, which were inspired by C# coroutines but don’t align well with C++. Coroutines allow for non-blocking concurrent code and are essentially functions that behave differently when called multiple times. A struct in C++ can represent a coroutine, transforming traditional code into coroutine format. However, a major issue arises with heap allocation in coroutines, leading to potential performance problems and lack of control in inlining. Macros become necessary for composing coroutines, as they don’t naturally fit together. The concept of promise types and the co_yield and co_await operators are essential in managing values and communication in coroutines.
https://probablydance.com/2021/10/31/c-coroutines-do-not-spark-joy/