If you don't need the side effect of post increment, then the pre increment version is the better choice.
In case of an int
it does not result in different code, but in case of an iterator you probably get better performance with pre increment because post increment needs to create a temporary copy of the original iterator. You can easily see that when comparing pre increment
class T {
T& operator++() {
this-> .... // do the increment
return *this;
}
}
with the post increment
class T {
T operator++(int) {
const T old{ *this };
this-> .... // do the increment
return old;
}
}
If the iterator is just a pointer then the compiler might be able to optimize so much that you don't see a difference, but if the iterator is more complex, then you will see a difference.
Of course the same applies to prefix and postfix decrement.