public member function
<string>
std::basic_string::back
charT& back();const charT& back() const;
Access last character
This function shall not be called on empty strings.
Parameters
noneReturn value
A reference to the last character in the basic_string.If the basic_string object is const-qualified, the function returns a
const charT&. Otherwise, it returns a charT&.charT is basic_string's character type (i.e., its first template parameter).Example
|
|
Output:
Complexity
Constant.Iterator validity
No changes.Data races
The container is accessed (neither the const nor the non-const versions modify the container).The reference returned can be used to access or modify characters. Concurrently accessing or modifying different characters is safe.
Exception safety
If the basic_string is not empty, the function never throws exceptions (no-throw guarantee).Otherwise, it causes undefined behavior.
See also
- basic_string::front
- Access first character (public member function)
- basic_string::push_back
- Append character to string (public member function)
- basic_string::pop_back
- Delete last character (public member function)
- basic_string::at
- Get character of string (public member function)
- basic_string::operator[]
- Get character of string (public member function)