我是贡献人,欢迎大家参与本题讨论。
参考答案:A
解析:
18.4(5) Whenever an exception is thrown and the search for a handler (18.3) encounters the outermost block of a function with a non-throwing exception specification, the function std::terminate() is called (18.5.1).(8) The exception specification for an implicitly-declared destructor, or a destructor without a noexcept-specifier , is potentially-throwing if and only if any of the destructors for any of its potentially constructed subobjects is potentially throwing.
可知,若类的子对象的析构函数并非可能抛出异常且该类的析构函数为隐式声明或未显式声明异常规范的,则该类的析构函数视为隐含noexcept(true)的。声明为noexcept(true)的函数若未在函数体内捕获到抛出的异常会直接调用std::terminate。相反,若析构函数有显式声明noexcept(false)等其他情况,异常是可以逃离析构函数体的。D错误。