
25 Apr
2010
25 Apr
'10
8:30 a.m.
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.
Updated examples and docs in Trunk, Thanks for catching this, John.