|
|
|
|
|
by xnormal
1677 days ago
|
|
I used something similar to Duff’s device to implement coroutines in C++ (pre-C++20). With some macros and using lambda function the result almost feels like part of the language. No UB. Static analysis will keep you from doing things like using values in local variables across yields (use lambda captures instead). Just avoid doing two CO_YIELD() in the same line because this macro uses __LINE__ for the switch case. |
|