bad_exception
描述 (Description)
这是意外处理程序抛出的异常。
声明 (Declaration)
以下是std :: bad_exception的声明。
class bad_exception;
C++11
class bad_exception;
参数 (Parameters)
没有
返回值 (Return Value)
没有
异常 (Exceptions)
No-throw guarantee - 没有成员抛出异常。
例子 (Example)
在下面的示例中为std :: bad_exception。
#include <iostream>
#include <exception>
#include <stdexcept>
void my_unexp() { throw; }
void test() throw(std::bad_exception) {
throw std::runtime_error("test error");
}
int main() {
std::set_unexpected(my_unexp);
try {
test();
} catch(const std::bad_exception& e) {
std::cerr << "Caught " << e.what() << '\n';
}
}
样本输出应该是这样的 -
Caught std::bad_exception