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; ~ret_typeret_type15 ~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 {}; } return_voidtask::promise_type25 void return_void () {} unhandled_exceptiontask::promise_type26 void unhandled_exception () { } thingtask::promise_type27 void thing (ret_type x) {} 28 }; 29 }; 30 31 struct awaiter 32 { await_readyawaiter33 bool await_ready() const { return true; } await_suspendawaiter34 void await_suspend (coroutine_handle<>) {} await_resumeawaiter35 ret_type await_resume() { return {}; } 36 }; 37 38 task my_coro()39my_coro () 40 { 41 ret_type r2{co_await awaiter{}}; 42 //ret_type r3 (std::move(r2)); 43 } 44 main()45int main() 46 { 47 auto x = my_coro (); 48 return 0; 49 } 50