This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[RFC] random access iterators: indexing rather than incrementingyields aliasing improvementsimprovements.
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: libstdc++ at gcc dot gnu dot org
- Cc: Nathan Myers <ncm at cantrip dot org>
- Date: Sun, 28 Sep 2003 15:29:54 +0200
- Subject: [RFC] random access iterators: indexing rather than incrementingyields aliasing improvementsimprovements.
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.