public static member function
<string>

std::char_traits::assign

character (1)
static void      assign (char_type& r, const char_type& c);
array (2)
static char_type assign (char_type* p, site_t n, char_type c);
character (1)
static void      assign (char_type& r, const char_type& c) noexcept;
array (2)
static char_type assign (char_type* p, site_t n, char_type c);
Assign character
Assigns c to a character (r) or to an array of characters (s).

(1) character
Assigns c to r, as if using r=c.
(2) array
Assigns c to the first n characters in the array pointed by s, each as if using operator=.

In the standard specializations of char_traits, this function behaves as the built-in operator=, but custom character traits classes may provide an alternative behavior whenever this is consistent with the assignment operation of its character type.

Parameters

r
An lvalue reference to character.
c
A character value.
p
A pointer to the array where the characters will be written.
n
Number of characters to fill with a value of c.

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

none

Complexity

Constant.

Exception safety

Unless s 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