public static member function


character (1)
static void       assign (char_type& r, const char_type& c);
array (2)
static char_type* assign (char_type* p, size_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.


An lvalue reference to character.
A character value.
A pointer to the array where the characters will be written.
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 (for (1)).
p (for (2)).



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