79235471

Date: 2024-11-28 23:03:46
Score: 0.5
Natty:
Report link

This is what I came up with:

template<std::ranges::range R> 
auto foo_coroutine(R&& rng) {
    if constexpr (std::is_lvalue_reference_v<R>)
        return foo_coroutine_impl(std::ranges::subrange{rng}, std::move(func));
    else if constexpr (std::ranges::borrowed_range<R>)
        return foo_coroutine_impl(std::move(rng), std::move(func));
    //Deduction fails for rvalue non borrowed ranges

}

auto foo_coroutine_impl(const std::ranges::borrowed_range auto rng) {
   /*...*/ 
}
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: dwto