To answer this from the βwhat you want to doβ view: it makes no sense to call i++++ for a start, because i++ does not return a reference to the variable i , but the value of i was before it was incremented. So i++++ will essentially do this:
- Copy
i to temporary variable t - Increment
i - Copy
t to temporary variable u - Increment
t - Drop both
t and u
So all that remains is one increment i .
++++i , on the other hand, just makes
- Increment
i - Increment
i , again
and it really can be useful not so much in the integer type, but, of course, when i is an iterator of nonrandom access, because then you cannot rely on i+=2 .
source share