Can pop_back() ever reduce the capacity of a vector? (C++)
问题 According to the C++ standard, is std::vector<T>::pop_back() ever allowed to reduce the capacity of the vector? I am asking because I would like to have a guarantee, that the following code will not throw an out of memory exception: my_vec.pop_back(); if (...) my_vec.push_back(...); Assume that my_vec is an std::vector<int> . I guess there are three possibilities: Yes, this can happen according to both C++03 and C++11. No, C++11 prohibits this (but C++03 does not). No, both C++03 and C++11