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_;
};
}
iterator(iterator&& other) noexcept;
Effects: Initializes
coroutine_
with
exchange(other.coroutine_, {}). iterator& operator=(iterator&& other) noexcept;
Effects: Equivalent to
coroutine_ = exchange(other.coroutine_, {}). 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_);
Preconditions: For some
generator object
x,
coroutine_ is in
*x.active_. Effects: Equivalent to
x.active_->top().resume(). Effects: Equivalent to
++*this. friend bool operator==(const iterator& i, default_sentinel_t);
Effects: Equivalent to: return i.coroutine_.done();