I am surprised to see that the standard C++ std::vector::pop_back()
mutator is not noexcept
, and so is permitted to throw exceptions. Surprised, because it is a destruction type operation, which should never need to allocate any resources.
When it practice could it throw an exception? Is it permitted to throw an exception only to propagate an exception thrown by the destructor of the last element of the vector? So a std::vector
holding values of a properly behaved class, which has a noexcept
destructor, will not throw exceptions from pop_back()
?