If I use reserve() to reserve enough elements for a vector, will push_back() (or insert()) throw any exceptions?
Is there a reference somewhere that specifies which stl function throw / not throw any exceptions?
Thank you.
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.
It won’t need to perform a reallocation, and so the vector itself won’t throw any exceptions. The elements you’re inserting might throw exceptions when being copied into the vector, though, so
push_backandinsertcan still throw exceptions.Yes, the C++ standard contains that information.