Debian Codegraph @

yo/coroutines/demo/corodir/iterator.h

raw
1 #ifndef INCLUDED_ITERATOR_H_
2 #define INCLUDED_ITERATOR_H_
3
4 // needs the Promise header (generatorpromise.h)
5
6 template <typename T>
7 class Iterator;
8
9 template<typename T>
10 bool operator==(Iterator<T> const &it, Sentinel) noexcept;
11
12 template<typename T>
13 class Iterator
14 {
15 friend bool operator==<>(Iterator<T> const &it, Sentinel) noexcept;
16
17 using Handle = std::coroutine_handle<Promise<T>>;
18
19 Handle d_coHandle = 0;
20
21 public:
22 Iterator() noexcept = default;
23 explicit Iterator(Handle handle) noexcept;
24
25 // Need the post-increment operator for the 'Range' concept.
26 void operator++(int);
27 Iterator &operator++();
28
29 typename Promise<T>::Reference operator*() const noexcept;
30 typename Promise<T>::Value *operator->() const noexcept;
31 };
32
33 #include "iterator.imp"
34
35 #endif