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

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


Paolo Carlini wrote:

> 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];

Sorry, I have blindly reproduced typos present in the
original posting. Of course is:

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

Paolo.



More information about the Libstdc++ mailing list