▲ | jeffbee 3 days ago | |||||||||||||
In this degenerate example, the completely straightforward way is tied for fastest as well. It's clear this has nothing to do with ranges.
| ||||||||||||||
▲ | vitus 2 days ago | parent [-] | |||||||||||||
> the completely straightforward way is tied for fastest as well. Is it, though? back_inserter should replicate push_back(), which incurs a move at the very minimum. The approach with emplace_back() does not. https://quick-bench.com/q/1zwemArsS0gtKwveR9FZsuRwT34 This also isn't the way C++20 wants us to work with ranges and views, either -- this is basically just std::transform as you'd write it 20 years ago, except with a container as the argument instead of your begin / end iterators (so, basically absl::c_transform). | ||||||||||||||
|