GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::basic_string::pop_back(3) C++ Standard Libary std::basic_string::pop_back(3)

std::basic_string::pop_back - std::basic_string::pop_back


void pop_back(); (since C++11)
(until C++20)
constexpr void pop_back(); (since C++20)


Removes the last character from the string.


Equivalent to erase(end()-1). The behavior is undefined if the string is empty.


(none)


(none)


Constant.


Throws nothing.

// Run this code


#include <cassert>
#include <string>
#include <iomanip>
#include <iostream>


int main()
{
std::string str("Short string!");
std::cout << "before=" << quoted(str) << '\n';
assert(str.size() == 13);


str.pop_back();
std::cout << " after=" << quoted(str) << '\n';
assert(str.size() == 12);


str.clear();
// str.pop_back(); // UB!
}


before="Short string!"
after="Short string"


push_back appends a character to the end
(public member function)
erase removes characters
(public member function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.