
24 Apr
2010
24 Apr
'10
8:48 p.m.
On 24 Apr 2010, at 16:55, strasser@uni-bremen.de wrote:
Zitat von Thorsten Ottosen <nesotto@cs.aau.dk>:
Hi John & co,
IIRC, std::copy() cannot use memcpy(), since the memory is allowed to overlap. Therefore it can only use memmove().
std::copy() doesn't allow overlapping ranges. -> std::copy_backward()
std::copy() does allow overlapping ranges. It requires the start of the range being copied to is not in the range from, but the end can be. std::copy(it, it + 5, it - 1); is legal. The equivalent memcpy(it, it - 1, 5); is not For exactly this reason, libstdc++ uses memmove rather than memcpy. memmove can also be used for copy_backward. Chris