25 Ranges library [ranges]

25.8 Range generators [coro.generator]

25.8.6 Class generator​::​iterator [coro.generator.iterator]

namespace std { template<class Ref, class Val, class Allocator> class generator<Ref, Val, Allocator>::iterator { public: using value_type = value; using difference_type = ptrdiff_t; iterator(iterator&& other) noexcept; iterator& operator=(iterator&& other) noexcept; reference operator*() const noexcept(is_nothrow_copy_constructible_v<reference>); iterator& operator++(); void operator++(int); friend bool operator==(const iterator& i, default_sentinel_t); private: coroutine_handle<promise_type> coroutine_; // exposition only }; }
iterator(iterator&& other) noexcept;
Effects: Initializes coroutine_ with exchange(other.coroutine_, {}).
iterator& operator=(iterator&& other) noexcept;
Effects: Equivalent to coroutine_ = exchange(other.coroutine_, {}).
Returns: *this.
reference operator*() const noexcept(is_nothrow_copy_constructible_v<reference>);
Preconditions: For some generator object x, coroutine_ is in *x.active_ and x.active_->top() refers to a suspended coroutine with promise object p.
Effects: Equivalent to: return static_cast<reference>(*p.value_);
iterator& operator++();
Preconditions: For some generator object x, coroutine_ is in *x.active_.
Effects: Equivalent to x.active_->top().resume().
Returns: *this.
void operator++(int);
Effects: Equivalent to ++*this.
friend bool operator==(const iterator& i, default_sentinel_t);
Effects: Equivalent to: return i.coroutine_.done();