[RFC] random access iterators: indexing rather than incrementing yields aliasing improvements improvements.

Paolo Carlini pcarlini@unitus.it
Sun Sep 28 13:29:00 GMT 2003


Hi everyone.

I'm reading with interest this discussion thread:

 http://groups.google.it/groups?dq=&hl=it&lr=&ie=UTF-8&threadm=9215d7ac.0309262129.3f014cc9%40posting.google.com&prev=/groups%3Fdq%3D%26num%3D25%26hl%3Dit%26lr%3D%26ie%3DUTF-8%26group%3Dcomp.lang.c%252B%252B.moderated%26start%3D25

which basically is about (used in libstdc++ for copy):

for (n = last - first; n > 0; --n)

  {
    *result = *first;
    ++first; ++result;
  }

vs

for (i = 0; i != n; ++n)
  result [n] = first [n];

The author argues in favor of the latter, in particular for
"complex" iterators...

I think Nathan did some benchmarks for pointers to char?!?
But what about other iterators?

Thanks,
Paolo.




More information about the Libstdc++ mailing list