3 ms·
> it++ Should be ++it. Post-increment is generally more expensive, especially when you don't know the exact type you're applying it to.
by zombot 2y ago
> it++
Should be ++it. Post-increment is generally more expensive, especially when you don't know the exact type you're applying it to.
- listeria 2y agoI'd normally agree with you, but in this case this function is meant to be used for vectorizable input so it doesn't really matter since it's using a random-access iterator, otherwise you should go with the usual std::count_if(). Then again, it doesn't hurt to be pedantic.
- zombot 2y agoIt's not about being pedantic, it's about building the right habits. Building a habit of using x++ instead of ++x is suboptimal.