| 1 |
#include <coroutine> |
| 2 |
#include <memory> |
| 3 |
|
| 4 |
struct task { |
| 5 |
struct promise_type { |
| 6 |
auto initial_suspend() noexcept { return std::suspend_always{}; } |
| 7 |
auto final_suspend() noexcept { return std::suspend_always{}; } |
| 8 |
void return_void() {} |
| 9 |
task get_return_object() { return task{}; } |
| 10 |
void unhandled_exception() noexcept {} |
| 11 |
}; |
| 12 |
|
| 13 |
~task() noexcept {} |
| 14 |
|
| 15 |
bool await_ready() const noexcept { return false; } |
| 16 |
void await_suspend(std::coroutine_handle<>) noexcept {} |
| 17 |
void await_resume() noexcept {} |
| 18 |
}; |
| 19 |
|
| 20 |
struct Id |
| 21 |
{ |
| 22 |
std::unique_ptr<int> value; |
| 23 |
}; |
| 24 |
|
| 25 |
task g(int); |
| 26 |
|
| 27 |
task f() { |
| 28 |
std::unique_ptr<Id> id; |
| 29 |
co_await g(*id->value); |
| 30 |
} |