Namespaces
Variants
Views
Actions

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}}
{{ddcl |
+
{{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}}
  
[[de:cpp/string/basic string/push back]]
+
{{langlinks|de|es|fr|it|ja|pt|ru|zh}}
[[es:cpp/string/basic string/push back]]
+
[[fr:cpp/string/basic string/push back]]
+
[[it:cpp/string/basic string/push back]]
+
[[ja:cpp/string/basic string/push back]]
+
[[pt:cpp/string/basic string/push back]]
+
[[ru:cpp/string/basic string/push back]]
+
[[zh:cpp/string/basic string/push back]]
+

Revision as of 00:02, 18 February 2020

 
 
 
std::basic_string
Member functions
Element access
Iterators
Capacity
Modifiers
basic_string::push_back
Search
Operations
Constants
Non-member functions
I/O
Comparison
(until C++20)(until C++20)(until C++20)(until C++20)(until C++20)(C++20)
Numeric conversions
(C++11)(C++11)(C++11)
(C++11)(C++11)
(C++11)(C++11)(C++11)
(C++11)
(C++11)
Literals
Helper classes
Deduction guides (C++17)

 
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

removes the last character
(public member function) [edit]