When copying data from one range to another, you have to be careful if there's partial overlap between the source and destination ranges. If the beginning of the destination range overlaps the tail of the source range, a plain sequential copy will garble the data. The C run-time library has memmove
in addition to memcopy
to handle such overlap problems.
I assume std::copy
works like memcopy
, in that it doesn't pay any regard to overlap between the source and destination regions. If you try to shift objects "down" in a std::vector
with std::copy
, you'll corrupt the data. Is there an STL algorithm analogue of memmove
to handle situations like this? Or should I roll my own with reverse iterators?