【发布时间】:2016-03-29 17:02:51
【问题描述】:
当我在 Windows 10 上的 Visual Studio 2015 中运行此代码时,看不到输出
That was unexpected
它适用于 Linux 上的 gcc 5.3。
class X {};
class Y {};
class Z : public X {};
class W {};
void f() throw(X, Y) // list what exceptions can be thrown
{
int n = 0;
if (n) throw X(); // OK
if (n) throw Z(); // also OK
throw W(); // will call std::unexpected()
}
int main() {
std::set_unexpected([] {
std::cout << "That was unexpected" << std::endl;
std::abort();
});
f();
}
【问题讨论】:
-
您可以尝试写信给
std::cerr。 -
我刚才试了std::cerr还是不行。
标签: c++ exception visual-studio-2015 iostream abort