【发布时间】:2016-07-23 10:29:03
【问题描述】:
我很难理解这一点。
double compute(double x, double y) noexcept
{
if (y == 0)
throw std::domain_error("y is zero");
return x / y;
}
这在clang中编译得很好(我没有检查gcc),但对我来说似乎是无稽之谈。为什么编译器会允许 noexcept 函数包含 throw 语句?
【问题讨论】:
-
抱歉,标题有误导性。真正的问题当然是“为什么编译器允许 noexcept 函数包含 throw 语句?”。
标签: c++ exception compilation tags noexcept