2 // { dg-do compile { target c++20 } }
7 // A move-only awaitable
8 class MoveOnlyAwaitable {
10 MoveOnlyAwaitable() = default;
11 MoveOnlyAwaitable(MoveOnlyAwaitable &&) = default;
12 MoveOnlyAwaitable &operator=(MoveOnlyAwaitable &&) = default;
14 MoveOnlyAwaitable(const MoveOnlyAwaitable &) = delete;
15 MoveOnlyAwaitable &operator=(const MoveOnlyAwaitable &) = delete;
17 bool await_ready() const noexcept { return false; }
18 void await_suspend(std::coroutine_handle<>) noexcept {}
19 void await_resume() {}
24 auto initial_suspend() const { return std::suspend_never{}; }
25 auto final_suspend() const noexcept { return std::suspend_never(); }
26 auto get_return_object() { return task{}; }
28 void unhandled_exception() {}
31 T &&await_transform(T &&t) {
32 return static_cast<T &&>(t);
38 bool await_ready() const { return false; }
39 void await_suspend(std::coroutine_handle<> awaiter) {}
40 void await_resume() {}
47 co_await MoveOnlyAwaitable();
52 auto moveonly = MoveOnlyAwaitable();
53 co_await std::move(moveonly);
57 // GCC 11.3:ERROR: error: use of deleted function 'MoveOnlyAwaitable::MoveOnlyAwaitable(const MoveOnlyAwaitable&)
60 auto moveonly = MoveOnlyAwaitable();