Mathias Gaunard wrote:
> On 31 août, 02:55, Thomas Maeder <mae...@glue.ch> wrote:
>
>> Provided the iterators are pointers (or close relatives to pointers),
>> which is the prerequisite for considiering the usage of memmove() or
>> memcpy(), std::copy can certainly determine whether the areas overlap.
>
> No, it can't.
> The compiler could do it, by doing alias analysis, which is a hard (NP-
> hard even) problem -- which is why you can't rely on the compiler
> doing it -- but a function certainly cannot.
Could you explain that in more detail? It seems to me that
std::copy<T*>(p,q,n) could certainly make use of std::less<T*> to check
whether [p,p+n) overlaps [q,q+n). What's the barrier to performing such
a comparison?
--
[ See
http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]