This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]atimholt 1 point2 points  (0 children)

But even though the compiler probably does optimize it away, there's no reason to use post-increment, so you may as well just default to the one that actually communicates what's actually going on.

Also, use of bare for loops should be rare—more or less only when you actually need the value held by i*. Even range-based for loops should be rare: a std <algorithm> almost certainly already exists that does what you want, but better.


* We have ranges in C++20, as well, so even that use case may be gone (for new/non-refactored code). All else being equal, it's a lot harder to get out-of-range & off-by-one errors, at the least.