在以下代码中,我认为断言不应该触发,但实际上它确实触发了。
struct A
{
~A() noexcept(false);
};
A f() noexcept;
int main()
{
static_assert(noexcept(f()), "f must be noexcept");
}
函数f()
明显是不抛出异常的,但是noexcept(f())
在gcc和clang中都会返回false(即noexcept
失败)。
我是否漏掉了什么或者这是一个bug?
noexcept
始终包括由表达式显式或隐式调用的所有内容。 - T.C.