That's the pedantically, fully reusable, correct version. Most of the time I would type something like this:
template<Range R, class Fun>
auto for_each(R&& range, Fun fun) {
return std::forward<R>(r)
| view::transform(std::move(fun))
| view::join;
}
I.e. I wouldn't bother to type check Fun and I would use a function instead of a function object. Both features are important for library code though.
Forward and move are still pointlessly noisy, I wish there was a keyword for those (especially forward). And I wish we had proper UFC instead of abusing pipes.
Forward and move are still pointlessly noisy, I wish there was a keyword for those (especially forward). And I wish we had proper UFC instead of abusing pipes.