[英]Why do I get error “'cout' in namespace 'std' does not name a type” when I use “using cout = std::cout;”?
[英]cout not shown when I call std::abort()
当我在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();
}
尽管接受了语法 ,但Visual C ++从未实现异常规范。
无论如何,它们在C ++ 11和更高版本中已被弃用。
可能是由于主要Windows C ++编译器不符合所致。
同样,我记得Visual C ++从未实现过std::uncaught_exception
,但是对此我不太确定。 值得在使用和依赖之前进行检查。 …经过文档检查 :Visual C ++ 2015 文档指出
”在设备上,仅Windows CE 5.00和更高版本(包括Windows Mobile 2005平台)支持
uncaught_exception
因此,在桌面平台上显然受到支持。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.