Issue 3899: co_yielding elements of an lvalue generator is unnecessarily inefficient (original) (raw)
namespace std { template<class Ref, class V, class Allocator> class generator<Ref, V, Allocator>::promise_type { public: […] auto yield_value(const remove_reference_t& lval) requires is_rvalue_reference_v && constructible_from<remove_cvref_t, const remove_reference_t&>;
template<class R2, class V2, class Alloc2, class Unused> requires same_as<typename generator<R2, V2, Alloc2>::yielded, yielded> auto yield_value(ranges::elements_of<generator<R2, V2, Alloc2>&&, Unused> g) noexcept; template<class R2, class V2, class Alloc2, class Unused> requires same_as<typename generator<R2, V2, Alloc2>::yielded, yielded> auto yield_value(ranges::elements_of<generator<R2, V2, Alloc2>&, Unused> g) noexcept;
template<ranges::input_range R, class Alloc> requires convertible_to<ranges::range_reference_t, yielded> auto yield_value(ranges::elements_of<R, Alloc> r) noexcept; […] }; }
[…]
template<class R2, class V2, class Alloc2, class Unused> requires same_as<typename generator<R2, V2, Alloc2>::yielded, yielded> auto yield_value(ranges::elements_of<generator<R2, V2, Alloc2>&&, Unused> g) noexcept; template<class R2, class V2, class Alloc2, class Unused> requires same_as<typename generator<R2, V2, Alloc2>::yielded, yielded> auto yield_value(ranges::elements_of<generator<R2, V2, Alloc2>&, Unused> g) noexcept;
-10- Preconditions: A handle referring to the coroutine whose promise object is
*this
is at the top of*_active_
of some generator objectx
. The coroutine referred to byg.range._coroutine_
is suspended at its initial suspend point.-11- Returns: An awaitable object of an unspecified type (7.6.2.4 [expr.await]) into which
g.range
is moved, whose memberawait_ready
returnsfalse
, whose memberawait_suspend
pushesg.range._coroutine_
into*x._active_
and resumes execution of the coroutine referred to byg.range._coroutine_
, and whose memberawait_resume
evaluatesrethrow_exception(_except_)
ifbool(_except_)
istrue
. Ifbool(_except_)
isfalse
, theawait_resume
member has no effects.-12- Remarks: A yield-expression that calls
this functionone of these functions has typevoid
(7.6.17 [expr.yield]).