Re: Why next/prev for iterators in C++0x?
On Apr 24, 9:02 am, "crea" <n...@invalid.com> wrote:
"Howard Hinnant" <howard.hinn...@gmail.com> wrote in message
news:c3808703-28c5-457e-acb4-4112f12862b4@d12g2000vbz.googlegroups.com...
On Apr 23, 5:53 pm, Marc <marc.gli...@gmail.com> wrote:
" ...
for (ForwardIterator1 j = std::next(i); j != last1; ++j)
if (pred(*i, *j))
++c1;
"
Just a small comment: I just read an article to say , that we
dont really (always) need to do ++j, but can do j++. The
reason is that the computer can trim the code many times when
it compiles. Also testing showed that there was no big
difference even if j++ was used. But I have to read the
article again...
On the other hand, I dont know why using ++j would be not good.
In practice, there's no valid technical reason for preferring
one over the other---it's just a question of which one you like
best. Politically speaking, however... some noted authors have
claimed otherwise, and have influences a large number of
programmers; it's easier to just use ++j than to argue with
them. (FWIW: K&R favored j++, and at least in the earlier
versions of his books, so did Stroustrup, so for older
programmers, who learned from the original masters, j++ often
seems more natural. Just because we've seen it more often,
however; not for any technical reason.)
--
James Kanze