【发布时间】:2016-07-20 20:36:15
【问题描述】:
我想了解如何在代码中使用Ensures()。如example 中给出的,如果我尝试使用Ensures() 如下...
int main(void)
{
int result = 0;
// Some calculation
Ensures(result == 255);
return 0;
}
如果result 变量不等于255,程序将崩溃并显示以下输出"terminate called without an active exception"。我的问题是如何正确使用Ensures()?
【问题讨论】:
-
如果在您的示例中调用了
std::terminate,那么它按原样工作。
标签: c++ c++11 cpp-core-guidelines guideline-support-library