| 7 | struct ClassWithCoro; |
| 8 | |
| 9 | struct my_resumable { |
| 10 | struct promise_type { |
| 11 | promise_type(ClassWithCoro& q1, int& q2) {} |
| 12 | my_resumable get_return_object() { |
| 13 | return my_resumable(my_resumable::handle_type::from_promise(*this)); |
| 14 | } |
| 15 | std::suspend_never initial_suspend() { return {}; } |
| 16 | std::suspend_always final_suspend() noexcept { return {}; } |
| 17 | void return_value(int) {} |
| 18 | void unhandled_exception() {} |
| 19 | }; |
| 20 | |
| 21 | using handle_type = std::coroutine_handle<promise_type>; |
| 22 | my_resumable(handle_type h) : m_handle(h) {} |
| 23 | ~my_resumable() { if (m_handle) m_handle.destroy(); } |
| 24 | my_resumable(my_resumable&& other) = delete; |
| 25 | handle_type m_handle; |
| 26 | }; |
| 27 | |
| 28 | struct ClassWithCoro { |
| 29 | int y{6}; |
no outgoing calls