| 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 |
|
| 9 |
struct dummy_coro |
| 10 |
{ |
| 11 |
using promise_type = dummy_coro; |
| 12 |
bool await_ready() noexcept { return false; } |
| 13 |
void await_suspend(std::coroutine_handle<>) noexcept { } |
| 14 |
void await_resume() noexcept { } |
| 15 |
dummy_coro get_return_object() { return {}; } |
| 16 |
dummy_coro initial_suspend() { return {}; } |
| 17 |
dummy_coro final_suspend() noexcept { return {}; } |
| 18 |
void return_void() { } |
| 19 |
void unhandled_exception() { } |
| 20 |
}; |
| 21 |
|
| 22 |
template <int ...I> |
| 23 |
dummy_coro |
| 24 |
foo() |
| 25 |
{ |
| 26 |
((co_await [](int){ return std::suspend_never{}; }(I)), ...); |
| 27 |
co_return; |
| 28 |
} |
| 29 |
|
| 30 |
void bar() { |
| 31 |
foo<1>(); |
| 32 |
} |