This is a follow-up to this question where I posted this program:
#include
#include
#include
#include
memcpy
and std::copy
each have their uses, std::copy
should(as pointed out by Cheers below) be as slow as memmove because there is no guarantee the memory regions will overlap. This means you can copy non-contiguous regions very easily (as it supports iterators) (think of sparsely allocated structures like linked list etc.... even custom classes/structures that implement iterators). memcpy
only work on contiguous reasons and as such can be heavily optimized.