| 1 |
// https://gcc.gnu.org/PR116502 |
| 2 |
#include <coroutine> |
| 3 |
|
| 4 |
struct SuspendNever { |
| 5 |
bool await_ready() noexcept; |
| 6 |
void await_suspend(std::coroutine_handle<>) noexcept; |
| 7 |
void await_resume() noexcept; |
| 8 |
}; |
| 9 |
|
| 10 |
struct Coroutine; |
| 11 |
|
| 12 |
struct PromiseType { |
| 13 |
Coroutine get_return_object(); |
| 14 |
SuspendNever initial_suspend(); |
| 15 |
SuspendNever final_suspend() noexcept; |
| 16 |
void return_void(); |
| 17 |
void unhandled_exception(); |
| 18 |
}; |
| 19 |
|
| 20 |
struct Coroutine { |
| 21 |
using promise_type = PromiseType; |
| 22 |
}; |
| 23 |
|
| 24 |
struct Awaiter { |
| 25 |
bool await_ready(); |
| 26 |
void await_suspend(std::coroutine_handle<>); |
| 27 |
[[nodiscard]] int& await_resume(); |
| 28 |
}; |
| 29 |
|
| 30 |
Coroutine foo() |
| 31 |
{ |
| 32 |
(void)co_await Awaiter {}; |
| 33 |
} |