std::generator::iterator(3)
okay bestie, welcome to the std::generator::iterator(3) page from the C++ Standard Libary manual π
β¨ NAME β¨
std::generator::iterator β literally std::generator::iterator. Thatβs the name, periodt.
π SYNOPSIS π
class /*iterator*/; (since C++23)
(exposition only*)
This is the return type of generator::begin.
It models indirectly_readable and input_iterator. Slay.
π MEMBER TYPES π
Member type β Definition:
value_typeβstd::generator::valuedifference_typeβstd::ptrdiff_t
π¦ DATA MEMBERS π¦
Member name β Definition:
coroutine_(private) β A coroutine handle of typestd::coroutine_handle<std::generator::promise_type>. (exposition-only member object*)
π MEMBER FUNCTIONS π
constructorβ constructs an iterator (public member function)operator=β assigns another iterator (public member function)operator*β returns an underlying value (public member function)operator++,operator++(int)β advances the iterator (public member function)
std::generator::iterator::iterator
/*iterator*/( /*iterator*/&& other ) noexcept; (since C++23)
Initializes coroutine_ with std::exchange(other.coroutine_, {});.
std::generator::iterator::operator=
/*iterator*/& operator=( /*iterator*/&& other ) noexcept; (since C++23)
Equivalent to coroutine_ = std::exchange(other.coroutine_, {});.
Returns: *this.
std::generator::iterator::operator*
reference operator*() const
noexcept( std::is_nothrow_copy_constructible_v<reference> );
(since C++23)
- Let
referencebe thestd::generatorβs underlying type. - Let for some
generatorobjectxitscoroutine_be in the stack*x.active_. - Let
x.active_->top()refer to a suspended coroutine with promise objectp.
Equivalent to return static_cast<reference>(*p.value_);.
std::generator::iterator::operator++
constexpr /*iterator*/& operator++(); (1) (since C++23)
constexpr void operator++( int ); (2) (since C++23)
- Let for some
generatorobjectxthecoroutine_be in the stack*x.active_. Equivalent tox.active_->top().resume(). Returns:*this. - Equivalent to
++*this;.
π NON-MEMBER FUNCTIONS π
operator==β compares the underlying iterator with a sentinel (C++23) (function)
operator==(std::generator::iterator)
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.
π EXAMPLE π
This section is incomplete Reason: no example
β CATEGORY β
* Todo no example
mwah π β source/version: http://cppreference.com, dated 2024.06.10. Go slay some coroutines, bestie π«Ά
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms