Difference between revisions of "cpp/string/basic string/push back"
From cppreference.com
< cpp | string | basic string
(exception guarantees per 21.4.1[string.require]) |
(P0980R1) |
||
Line 1: | Line 1: | ||
{{cpp/string/basic_string/title | push_back}} | {{cpp/string/basic_string/title | push_back}} | ||
{{cpp/string/basic_string/navbar}} | {{cpp/string/basic_string/navbar}} | ||
− | {{ | + | {{dcl begin}} |
+ | {{dcl rev multi | ||
+ | | until1=c++20 | dcl1= | ||
void push_back( CharT ch ); | void push_back( CharT ch ); | ||
+ | | dcl2= | ||
+ | constexpr void push_back( CharT ch ); | ||
}} | }} | ||
+ | {{dcl end}} | ||
Appends the given character {{tt|ch}} to the end of the string. | Appends the given character {{tt|ch}} to the end of the string. | ||
Line 30: | Line 35: | ||
{{dsc end}} | {{dsc end}} | ||
− | + | {{langlinks|de|es|fr|it|ja|pt|ru|zh}} | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + |
Revision as of 00:02, 18 February 2020
void push_back( CharT ch ); |
(until C++20) | |
constexpr void push_back( CharT ch ); |
(since C++20) | |
Appends the given character ch
to the end of the string.
Contents |
Parameters
ch | - | the character to append |
Return value
(none)
Complexity
Amortized constant.
Exceptions
If an exception is thrown for any reason, this function has no effect (strong exception guarantee).(since C++11)
If the operation would result in size() > max_size()
, throws std::length_error.
See also
(DR*) |
removes the last character (public member function) |