Operator++(int): A case for post-incrementing

If you love writing efficient code, you probably cringe when you see code like this, using post-increment for no gain:

for ( int i = 0; i < max_value; i++ )
{ // do stuff 
}

instead of :

for ( int i = 0; i < max_value; ++i )
{ // do stuff 
}

There are reasons to prefer one over the other. First, let’s start with the signature.

T& T::operator++(); // pre-increment

// vs 

T T::operator++(int); / post-increment
Continue readingOperator++(int): A case for post-incrementing