std::genera...:yield_value(3)
πΈ NAME πΈ
std::generator::promise_type::yield_value β std::generator::promise_type::yield_value π
okay bestie, this is the page for std::genera...:yield_value(3) from the C++ Standard Libary manual, and we're literally about to get into it. no cap, it's giving coroutine internals with main character energy β¨
β¨ Synopsis β¨
std::suspend_always yield_value( yielded val ) noexcept;
(1) (since C++23)
auto yield_value( const std::remove_reference_t<yielded>& lval )
requires std::is_rvalue_reference_v<yielded> &&
std::constructible_from<std::remove_cvref_t<yielded>,
const std::remove_reference_t<yielded>&>;
(2) (since C++23)
template< class R2, class V2, class Alloc2, class Unused >
requires std::same_as<typename std::generator<T2, V2, Alloc2>::yielded, yielded>
auto yield_value( ranges::elements_of<std::generator<T2, V2, Alloc2>&&,
Unused> g ) noexcept;
(3) (since C++23)
template< ranges::input_range R, class Alloc >
requires std::convertible_to<ranges::range_reference_t<R>, yielded>
auto yield_value( ranges::elements_of<R, Alloc> r ) noexcept;
(4) (since C++23)
An implementation of coroutine interface functions used internally to support operator co_yield π
(yielded is a reference type defined in std::generator.)
- Assigns
std::addressof(val)tovalue_. Returns{}π - Returns an awaitable object of an unspecified type that stores an object of type
std::remove_cvref_t<yielded>direct-non-list-initialized withlval, whose member functions are configured so thatvalue_points to that stored object. Then suspends the coroutine π΄ - Let
xbe some generator object.
Returns an awaitable object of an unspecified type into which g.range is moved,
- whose member
await_readyreturnsfalse, - whose member
await_suspendpushesg.range.coroutine_into*x.active_and - resumes execution of the coroutine referred to by
g.range.coroutine_, and - whose member
await_resumeevaluatesstd::rethrow_exception(except_)ifbool(except_)is true.- If
bool(except_)is false, theawait_resumemember has no effects.
The coroutine referred to by g.range.coroutine_ must be suspended at its initial suspend point. Otherwise the behavior is undefined π¨
- Equivalent to:
auto nested = [](std::allocator_arg_t, Alloc, ranges::iterator_t<R> i,
ranges::sentinel_t<R> s) ->
std::generator<yielded, ranges::range_value_t<R>, Alloc>
{
for (; i != s; ++i)
co_yield static_cast<yielded>(*i);
};
return yield_value(ranges::elements_of(nested(
allocator_arg, r.allocator, ranges::begin(r.range),
ranges::end(r.range))));
2,3) A handle referring to the coroutine whose promise object is *this must be at the top of *active_ of some generator object. Otherwise the behavior is undefined. π
2-4) A yield-expression that calls these overload has the type void.
π Parameters π
valβ a value which is a result of the yield-expression evaluationlvalβ an lvalue which is a result of the yield-expression evaluationgβ a range of elements produced by a generatorrβ a range of elements
π¦ Return value π¦
- The awaitable object of type
std::suspend_always. 2-4. An awaitable object of an unspecified type as described above.
π Exceptions π
- May throw any exception thrown by the initialization of the stored object.
made with π from http://cppreference.com, dated 2024.06.10, for std::genera...:yield_value(3) β bye 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