| 1 |
#ifndef INCLUDED_GENERATOR_H_ |
| 2 |
#define INCLUDED_GENERATOR_H_ |
| 3 |
|
| 4 |
template<typename T> |
| 5 |
class [[nodiscard]] Generator |
| 6 |
{ |
| 7 |
friend class Promise<T>; |
| 8 |
|
| 9 |
using Handle = std::coroutine_handle<Promise<T>>; |
| 10 |
|
| 11 |
Handle d_handle = 0; |
| 12 |
|
| 13 |
public: |
| 14 |
using promise_type = Promise<T>; |
| 15 |
|
| 16 |
Generator() noexcept = default; |
| 17 |
|
| 18 |
Generator(Generator &&other) noexcept; |
| 19 |
~Generator(); |
| 20 |
|
| 21 |
Generator& operator=(Generator &&tmp) noexcept; |
| 22 |
|
| 23 |
Iterator<T> begin(); |
| 24 |
Sentinel end() noexcept; |
| 25 |
|
| 26 |
void swap(Generator &other) noexcept; |
| 27 |
|
| 28 |
private: |
| 29 |
explicit Generator(Handle handle) noexcept; |
| 30 |
}; |
| 31 |
|
| 32 |
#include "generator.imp" |
| 33 |
|
| 34 |
#endif |