2 //===----------------------------------------------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 // UNSUPPORTED: c++98, c++03, c++11
13 // See https://bugs.llvm.org/show_bug.cgi?id=33271
16 #include <experimental/coroutine>
19 using namespace std::experimental;
23 coro_t get_return_object() {
24 return coroutine_handle<promise_type>::from_promise(*this);
26 suspend_never initial_suspend() { return {}; }
27 suspend_never final_suspend() { return {}; }
29 void unhandled_exception() {}
31 coro_t(coroutine_handle<promise_type> hh) : h(hh) {}
32 coroutine_handle<promise_type> h;
36 bool await_ready() { return false; }
37 void await_resume() {}
38 template <typename F> bool await_suspend(F) { return false; }
42 bool await_ready() { return false; }
43 void await_resume() {}
44 template <typename F> bool await_suspend(F) { return true; }
47 bool f_started, f_resumed = false;
54 bool g_started, g_resumed = false;
62 assert(!f_started && !f_resumed && !g_started && !g_resumed);
64 assert(f_started && !f_resumed);
66 assert(f_started && !f_resumed);
68 assert(g_started && g_resumed);