| 1 |
#if __has_include (<coroutine>) |
| 2 |
#include <coroutine> |
| 3 |
using namespace std; |
| 4 |
#elif defined (__clang__) && __has_include (<experimental/coroutine>) |
| 5 |
#include <experimental/coroutine> |
| 6 |
using namespace std::experimental; |
| 7 |
#endif |
| 8 |
#include <utility> |
| 9 |
|
| 10 |
struct ret_type |
| 11 |
{ |
| 12 |
ret_type () = default; |
| 13 |
ret_type (const ret_type&) = delete; |
| 14 |
//ret_type (ret_type&&) = default; |
| 15 |
~ret_type() {} |
| 16 |
}; |
| 17 |
|
| 18 |
struct task |
| 19 |
{ |
| 20 |
struct promise_type |
| 21 |
{ |
| 22 |
auto get_return_object () -> task { return {}; } |
| 23 |
auto initial_suspend () -> suspend_always { return {}; } |
| 24 |
auto final_suspend () noexcept -> suspend_always { return {}; } |
| 25 |
void return_void () {} |
| 26 |
void unhandled_exception () { } |
| 27 |
void thing (ret_type x) {} |
| 28 |
}; |
| 29 |
}; |
| 30 |
|
| 31 |
struct awaiter |
| 32 |
{ |
| 33 |
bool await_ready() const { return true; } |
| 34 |
void await_suspend (coroutine_handle<>) {} |
| 35 |
ret_type await_resume() { return {}; } |
| 36 |
}; |
| 37 |
|
| 38 |
task |
| 39 |
my_coro () |
| 40 |
{ |
| 41 |
ret_type r2{co_await awaiter{}}; |
| 42 |
//ret_type r3 (std::move(r2)); |
| 43 |
} |
| 44 |
|
| 45 |
int main() |
| 46 |
{ |
| 47 |
auto x = my_coro (); |
| 48 |
return 0; |
| 49 |
} |