Use preincrement with iterators

This tip submitted by Dirk Tjantele on 2010-09-06 07:55:37. It has been viewed 6407 times.
Rating of 1.9 with 30 votes

When using the unary operators ++ and -- on an STL interator, use the pre-increment and pre-decrement versions. This will run faster than the post-increment versions as it will avoid the need to hold on to a copy of the old state of the iterator to return.