| 1 | #ifndef INCLUDED_DIGIT_ |
| 2 | #define INCLUDED_DIGIT_ |
| 3 | |
| 4 | #include "../../promisebase/promisebase.h" |
| 5 | #include "../awaiter/awaiter.h" |
| 6 | |
| 7 | class Digit |
| 8 | { |
| 9 | struct State: public PromiseBase<Digit, State> |
| 10 | { |
| 11 | template <typename Handler> |
| 12 | Awaiter await_transform(Next<Handler> &&next); |
| 13 | }; |
| 14 | |
| 15 | std::coroutine_handle<State> d_handle; |
| 16 | |
| 17 | public: |
| 18 | using promise_type = State; |
| 19 | using Handle = std::coroutine_handle<State>; |
| 20 | |
| 21 | explicit Digit(Handle handle); |
| 22 | ~Digit(); |
| 23 | |
| 24 | Handle handle() const; |
| 25 | }; |
| 26 | |
| 27 | template <typename Handler> |
| 28 | Awaiter Digit::State::await_transform(Next<Handler> &&next) |
| 29 | { |
| 30 | return Awaiter{ next.d_handle }; |
| 31 | } |
| 32 | |
| 33 | inline Digit::Handle Digit::handle() const |
| 34 | { |
| 35 | return d_handle; |
| 36 | } |
| 37 | |
| 38 | extern Digit g_digit; |
| 39 | |
| 40 | #endif |