std::memmove (3) - Linux Manuals
std::memmove: std::memmove
NAME
Synopsis
Defined in header <cstring>
void* memmove( void* dest, const void* src, std::size_t count );
Copies count characters from the object pointed to by src to the object pointed to by dest. Both objects are reinterpreted as arrays of unsigned char.
The objects may overlap: copying takes place as if the characters were copied to a temporary character array and then the characters were copied from the array to dest.
If the objects are potentially-overlapping or not TriviallyCopyable, the behavior of memmove is not specified and may_be_undefined.
Parameters
dest - pointer to the memory location to copy to
src - pointer to the memory location to copy from
count - number of bytes to copy
Return value
dest
Notes
Despite being specified "as if" a temporary buffer is used, actual implementations of this function do not incur the overhead of double copying or extra memory. For small count, it may load up and write out registers; for larger blocks, a common approach (glibc and bsd libc) is to copy bytes forwards from the beginning of the buffer if the destination starts before the source, and backwards from the end otherwise, with a fall back to std::memcpy when there is no overlap at all.
Example
// Run this code
Output:
See also
memcpy (function)
memset (function)
wmemmove (function)
copy
copy_if copies a range of elements to a new location
(C++11)
copy_backward (function template)
is_trivially_copyable checks if a type is trivially copyable
(C++11)