14 ms·
Normal for loops can't really make that work, they're too general, but range for loops plausibly could. Something like for(auto&& e : range) { std:
by pbsd 2y ago
Normal for loops can't really make that work, they're too general, but range for loops plausibly could. Something like
for(auto&& e : range) {
std::print("{}" e);
join {
std::print(", ");
}
}
where join {} is effectively syntax sugar for if(std::next(__first) != __last) {}.
The fmt library makes this sort of task easier by providing the join adaptor; this example would become
fmt::print("{}", fmt::join(range, ", "));