class /*iterator*/; | (since C++23) |
The return type of generator::begin
. The name iterator
is for exposition purposes only.
Models indirectly_readable
and input_iterator
.
Member type | Definition |
---|---|
value_type | std::generator::value |
difference_type | std::ptrdiff_t |
Typical implementations of iterator
hold only one non-static data members:
std::coroutine_handle<std::generator::promise_type>
(shown here as coroutine_
for exposition only).
(C++23) | constructs an iterator (public member function) |
(C++23) | assigns another iterator (public member function) |
(C++23) | returns an underlying value (public member function) |
(C++23) | advances the iterator (public member function) |
/*iterator*/( /*iterator*/&& other ) noexcept; | (since C++23) |
Initializes coroutine_
with std::exchange(other.coroutine_, {});
.
/*iterator*/& operator=( /*iterator*/&& other ) noexcept; | (since C++23) |
Equivalent to coroutine_ = std::exchange(other.coroutine_, {});
.
Returns: *this
.
reference operator*() const noexcept( std::is_nothrow_copy_constructible_v<reference> ); | (since C++23) |
reference
be the std::generator
's underlying type. x
its coroutine_
be in the stack *x.active_
. x.active_->top()
refer to a suspended coroutine with promise object p
. Equivalent to return static_cast<reference>(*p.value_);
.
constexpr /*iterator*/& operator++(); | (1) | (since C++23) |
constexpr void operator++( int ); | (2) | (since C++23) |
x
the coroutine_
be in the stack *x.active_
.x.active_->top().resume()
.*this
.++*this;
.
(C++23) | compares the underlying iterator with a sentinel (function) |
friend bool operator==( const /*iterator*/& i, std::default_sentinel_t ); | (since C++23) |
Equivalent to return i.coroutine_.done();
.
The !=
operator is synthesized from operator==
.
This function is not visible to ordinary unqualified or qualified lookup, and can only be found by argument-dependent lookup when std::generator::iterator
is an associated class of the arguments.
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/coroutine/generator/iterator