string::assign
Assign characters to a string.
Synopsis
string&
assign(
std::size_t count,
char ch); (1)
string&
assign(
string const& other); (2)
string&
assign(
string&& other); (3)
string&
assign(
char const* s,
std::size_t count); (4)
string&
assign(
char const* s); (5)
template<
class InputIt>
string&
assign(
InputIt first,
InputIt last); (6)
string&
assign(
string_view s); (7)
Description
Replace the contents with count
copies of character ch
.
Complexity
Linear in count
.
Exception Safety
Strong guarantee. Calls to memory_resource::allocate
may throw.
Template Parameters
Type | Description |
---|---|
|
The type of the iterators. |
Return Value
*this
Return Value
*this
Return Value
*this
Return Value
*this
Return Value
*this
Return Value
*this
Return Value
*this
Parameters
Name | Description |
---|---|
|
The size of the resulting string. |
|
The value to initialize characters of the string with. |
|
The string to use as a source to copy from. |
|
A pointer to a character string used to copy from. |
|
An input iterator pointing to the first character to insert, or pointing to the end of the range. |
|
An input iterator pointing to the end of the range. |
Exceptions
Type | Thrown On |
---|---|
|
|