public static member function
<string>

std::char_traits::move

static char_type* move (char_type* dest, const char_type* src, size_t n);
Move character sequence
Copies the sequence of n characters pointed by src to the array pointed by dest, even if the ranges overlap.

All character traits types shall implement the function as if the individual characters were assigned using member assign.

Parameters

dest
Pointer to an array where the copied characters are written.
src
Pointer to an array with the n characters to copy.
n
Number of characters to copy.

Notice that the function will consider that the length of both dest and src sequences is n characters, independently on whether any of them contains null-characters.
Member type char_type is the character type (i.e., the class template parameter in char_traits).
size_t is an unsigned integral type.

Return Value

Returns dest.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// char_traits::move
#include <iostream>   // std::cout
#include <string>     // std::char_traits

int main ()
{
  char foo[] = "---o............";
  std::cout << foo << '\n';
  std::char_traits<char>::move (foo+3,foo,4);
  std::cout << foo << '\n';
  std::char_traits<char>::move (foo+6,foo,7);
  std::cout << foo << '\n';
  return 0;
}


Output:
---o............
------o.........
------------o...

Complexity

Linear in n.

Exception safety

Unless either dest or src does not point to an array long enough, this member function never throws exceptions (no-throw guarantee) in any of the standard specializations.
Otherwise, it causes undefined behavior.

See also