A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/string/char_traits/assign/ below:

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, 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.



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 (for (1)).
p (for (2)).

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
char_traits::eq
Compare characters for equality (public static member function)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4