D
David Hilsee
<snip>Filipe Valepereiro said:Always use ++u, since they're suposed to be faster.
If you use iterator's then you must allways use ++u.
this is a recommendation from Bjarne Stroustrup book,
see chapter about Iterators
If you're referring to the "advice" section, then let me point out that he
wisely uses the word "prefer" and not "always". In certain cases, favoring
preincrement leads to awkward code that isn't necessarily more efficient.
If you're going to wind up writing
SomeIterator tmp(i);
++i;
doSomething(tmp);
// no other usage of tmp after this
then you might as well write
doSomething( i++ );
This type of code most often occurs when iterating over certain containers
and erasing elements as you go.