std::generator<Ref,V,Allocator>::promise_type::yield_value
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> && |
(2) | (since C++23) |
template< class R2, class V2, class Alloc2, class Unused > requires std::same_as<typename std::generator<T2, V2, Alloc2>::yielded, |
(3) | (since C++23) |
template< class R2, class V2, class Alloc2, class Unused > requires std::same_as<typename std::generator<T2, V2, Alloc2>::yielded, |
(4) | (since C++23) |
template< ranges::input_range R, class Alloc > requires std::convertible_to<ranges::range_reference_t<R>, yielded> |
(5) | (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.)
yielded
>. x is direct-non-list-initialized with lval, whose member functions are configured so that value_
points to that stored object. Then suspends the coroutine.Returns an awaitable object of an unspecified type into which g.range is moved,
- whose member await_ready returns false,
- whose member await_suspend pushes g.range.coroutine_ into *x.
active_
and - resumes execution of the coroutine referred to by g.range.coroutine_, and
- whose member await_resume evaluates
- std::rethrow_exception(except_) if bool(except_) is true.
- If bool(except_) is false, the await_resume member has no effects.
auto nested = [](std::allocator_arg_t, Alloc, ranges::iterator_t<R> i, ranges::sentinel_t<R> s) -> std::generator<yielded, void, 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))));
active_
of some generator object. Otherwise, the behavior is undefined.Contents |
[edit] Parameters
val | - | a value which is a result of the yield-expression evaluation |
lval | - | an lvalue which is a result of the yield-expression evaluation |
g | - | a range of elements produced by a generator |
r | - | a range of elements |
[edit] Return value
[edit] Exceptions
[edit] Example
This section is incomplete Reason: no example |
[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 3899 | C++23 | yield_value on a range of elements produced by lvalue generatorused generic elements_of overload
|
used special elements_of overload for such generators
|
LWG 4119 | C++23 | range_value_t in generator 's template argument as partof the return type of nested in (5) may be ill-formed |
used void |