It looks like there are now test cases in the range-v3 library that show how to do this correctly. It is necessary to add the views::cache1
operator into the pipeline:
auto rng = views::iota(0,4)
| views::transform([](int i) {return std::string(i, char('a'+i));})
| views::cache1
| views::join('-');
check_equal(rng, {'-','b','-','c','c','-','d','d','d'});
CPP_assert(input_range<decltype(rng)>);
CPP_assert(!range<const decltype(rng)>);
CPP_assert(!forward_range<decltype(rng)>);
CPP_assert(!common_range<decltype(rng)>);
so the solutions for the OP’s question would be to write
auto rng = src | views::transform(f) | views::cache1 | views::join;