Namespaces
Variants
Actions

std::basic_string<CharT,Traits,Allocator>::push_back

From cppreference.com
< cpp‎ | string‎ | basic string
 
 
 
std::basic_string
 
void push_back( CharT ch );
(constexpr since C++20)

Appends the given character ch to the end of the string.

Contents

[edit] Parameters

ch - the character to append

[edit] Return value

(none)

[edit] Complexity

Amortized constant.

[edit] Exceptions

If the operation would cause size() to exceed max_size(), throws std::length_error.

If an exception is thrown for any reason, this function has no effect (strong exception safety guarantee).

[edit] Example

#include <iomanip>
#include <iostream>
#include <string>
 
int main()
{