Is there any chance for a call to std::vector<T>::clear() to throw an exception?
Is there any chance for a call to std::vector<T>::clear() to throw an exception?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No.
What happens if my element type destructor throws?
In C++11,
std::vector<T>::clear()is markednoexcept([n3290: 23.3.6/1]).Any exceptions falling out of
~Tcould be caught by the implementation, so thatclear()itself may not throw anything. If they’re not, and it does, the exception is “unexpected” and terminates the process rather than propagating: