The nested coroutine is specified to return generator<yielded, ranges::range_value_t<R>, Alloc>
which can be problematic as the value type of R
is really irrelevant to yielded
,
unnecessarily violating the generator
's Mandates (demo):
#include <generator>
#include <vector>
std::generator<std::span<int>> f() {
std::vector<int> v;
co_yield v; // ok
}
std::generator<std::span<int>> g() {
std::vector<std::vector<int>> v;
co_yield std::ranges::elements_of(v); // hard error
}
This proposed resolution is to change the second template parameter from range_value_t<R>
to void
since that type doesn't matter to us.