Re: difference between i++ and ++i in a for loop
On Feb 18, 11:56 pm, Alexander Gutenev <gute...@gmail.com> wrote:
On 18 =C6=C5=D7, 01:46, James Kanze <james.ka...@gmail.com> wrote:
Depending on the types involved, and how the compiler
handles them, there may be a difference in performance.
\u0161At least, people keep claiming this; I've done a lot
of measurements, and I've never been able to find any; I
think it's one of those myths that people like to
perpetrate.
For int there would not be any differene, but you can see the
diference on the code like:
for (std::set<int>::iterator i = s.begin(); i != s.end(); ++i);
vs
for (std::set<int>::iterator i = s.begin(); i != s.end(); i++);
I didn't see it when I measured. I measured *all* of the
iterators in the standard library (using the g++
implementations), and found no difference for any of them.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34