| 1 |
#include <coroutine> |
| 2 |
|
| 3 |
struct Promise; |
| 4 |
|
| 5 |
struct Handle : std::coroutine_handle<Promise> { |
| 6 |
using promise_type = Promise; |
| 7 |
}; |
| 8 |
|
| 9 |
struct Promise { |
| 10 |
Handle get_return_object() noexcept { |
| 11 |
return {Handle::from_promise(*this)}; |
| 12 |
} |
| 13 |
std::suspend_never initial_suspend() const noexcept { return {}; } |
| 14 |
std::suspend_never final_suspend() const noexcept { return {}; } |
| 15 |
void return_void() const noexcept {} |
| 16 |
void unhandled_exception() const noexcept {} |
| 17 |
}; |
| 18 |
|
| 19 |
Handle Coro() { |
| 20 |
struct Awaiter : std::suspend_never { |
| 21 |
int await_resume() { return 0; } |
| 22 |
}; |
| 23 |
|
| 24 |
[] (int x = co_await Awaiter{}){}; // { dg-error ".co_await. cannot be used in default arguments" } |
| 25 |
co_return; |
| 26 |
} |
| 27 |
|
| 28 |
int main() { |
| 29 |
Coro(); |
| 30 |
|
| 31 |
return 0; |
| 32 |
} |