What happens if an exception escapes from a function declared noexcept?
Correct answer B. std::terminate is called
Explanation
noexcept is a promise that the function will not throw. If an exception does try to leave it, the runtime calls std::terminate instead of propagating it further, and stack unwinding may not happen. Because callers rely on the promise, for example std::vector moves elements only through noexcept move constructors, the guarantee must be kept carefully.
Answer checked How we write and check questions
Discussion