Resolving confusion over how to return from a C++ coroutine

211 · Raymond Chen · Jan. 14, 2022, 3:21 p.m.
A customer was having trouble writing a coroutine using C++/WinRT. This function compiled successfully: winrt::IAsyncOperation<bool> HelperFunction() { /* no other co_return statements */ co_return true; } But once they added a condition, it stopped compiling successfully: winrt::IAsyncOperation<bool> MainFunction() { ... if (condition) { ... The post Resolving confusion over how to return from a C++ coroutine appeared first on The Old New Thing....