namespace std {
template <typename... T> struct coroutine_traits;
template <class Promise = void> struct coroutine_handle {
coroutine_handle() = default;
static coroutine_handle from_address(void *) noexcept;
};
template <> struct coroutine_handle<void> {
static coroutine_handle from_address(void *) noexcept;
coroutine_handle() = default;
template <class PromiseType>
coroutine_handle(coroutine_handle<PromiseType>) noexcept;
};
}
struct suspend_always {
bool await_ready() noexcept;
void await_suspend(std::coroutine_handle<>) noexcept;
void await_resume() noexcept;
};
template <typename... Args> struct std::coroutine_traits<void, Args...> {
struct promise_type {
void get_return_object() noexcept;
suspend_always initial_suspend() noexcept;
suspend_always final_suspend() noexcept;
void return_void() noexcept;
promise_type();
~promise_type() noexcept;
void unhandled_exception() noexcept;
};
};
struct CopyOnly {
int val;
CopyOnly(const CopyOnly&) noexcept;
CopyOnly(CopyOnly&&) = delete;
~CopyOnly();
};
struct MoveOnly {
int val;
MoveOnly(const MoveOnly&) = delete;
MoveOnly(MoveOnly&&) noexcept;
~MoveOnly();
};
struct MoveAndCopy {
int val;
MoveAndCopy(const MoveAndCopy&)noexcept;
MoveAndCopy(MoveAndCopy&&) noexcept;
~MoveAndCopy();
};
void consume(int,int,int) noexcept;
void f(int val, MoveOnly moParam, MoveAndCopy mcParam) {
consume(val, moParam.val, mcParam.val);
co_return;
}
template <typename T, typename U>
void dependent_params(T x, U, U y) {
co_return;
}
struct A {
int WontFitIntoRegisterForSure[128];
A();
A(A&&) noexcept;
~A();
};
struct B {
int WontFitIntoRegisterForSure[128];
B();
B(B&&) noexcept;
~B();
};
void call_dependent_params() {
dependent_params(A{}, B{}, B{});
}
struct promise_matching_constructor {};
template <>
struct std::coroutine_traits<void, promise_matching_constructor, int, float, double> {
struct promise_type {
promise_type(promise_matching_constructor, int, float, double) {}
promise_type() = delete;
void get_return_object() {}
suspend_always initial_suspend() { return {}; }
suspend_always final_suspend() noexcept { return {}; }
void return_void() {}
void unhandled_exception() {}
};
};
void coroutine_matching_promise_constructor(promise_matching_constructor, int, float, double) {
co_return;
}
struct some_class;
struct method {};
template <typename... Args> struct std::coroutine_traits<method, Args...> {
struct promise_type {
promise_type(some_class&, float);
method get_return_object();
suspend_always initial_suspend();
suspend_always final_suspend() noexcept;
void return_void();
void unhandled_exception();
};
};
struct some_class {
method good_coroutine_calls_custom_constructor(float);
};
method some_class::good_coroutine_calls_custom_constructor(float) {
co_return;
}