| 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 |
std::suspend_never yield_value(int) { return {}; } |
| 18 |
}; |
| 19 |
|
| 20 |
Handle Coro() { |
| 21 |
[] (int x = co_yield 1){}; // { dg-error ".co_yield. cannot be used in default arguments" } |
| 22 |
co_return; |
| 23 |
} |
| 24 |
|
| 25 |
int main() { |
| 26 |
Coro(); |
| 27 |
|
| 28 |
return 0; |
| 29 |
} |