public member function
<string>
std::string::operator+=
| string (1) | string& operator+= (const string& str); |
|---|---|
| c-string (2) | string& operator+= (const char* s); |
| character (3) | string& operator+= (char c); |
| string (1) | string& operator+= (const string& str); |
|---|---|
| c-string (2) | string& operator+= (const char* s); |
| character (3) | string& operator+= (char c); |
| initializer list (4) | string& operator+= (initializer_list<char> il); |
Append to string
(See member function append for additional appending options).
Parameters
- str
- A string object, whose value is copied at the end.
- s
- Pointer to a null-terminated sequence of characters.
The sequence is copied at the end of the string. - c
- A character, which is appended to the current value of the string.
- il
- An initializer_list object.
These objects are automatically constructed from initializer list declarators.
The characters are appended to the string, in the same order.
Return Value
*thisExample
|
|
Output:
Complexity
Unspecified, but generally up to linear in the new string length.Iterator validity
Any iterators, pointers and references related to this object may be invalidated.Data races
The object is modified.Exception safety
Strong guarantee: if an exception is thrown, there are no changes in the string.
If the resulting string length would exceed the max_size, a length_error exception is thrown.
A bad_alloc exception is thrown if the function needs to allocate storage and fails.
See also
- string::append
- Append to string (public member function)
- string::assign
- Assign content to string (public member function)
- string::operator=
- String assignment (public member function)
- string::insert
- Insert into string (public member function)
- string::replace
- Replace portion of string (public member function)