C++11,`noexcept` 说明符,定义与声明

C++11, `noexcept` specifier, definition versus declaration

如果声明的函数具有 noexcept 说明符(noexceptnoexcept(true)noexcept(false) 或任何其他计算结果为 [=15 的 noexcept(expr) =] 或 false), 但它是在另一个地方定义的,我是否需要在定义中再次指定 noexcept 说明符,或者只在其前向声明中指定?

[except.spec]/p4:

If any declaration of a function has an exception-specification that is not a noexcept-specification allowing all exceptions, all declarations, including the definition and any explicit specialization, of that function shall have a compatible exception-specification.

noexcept(some-constant-expression-that-evaluates-to-false) 可以省略。所有声明中都必须存在任何其他内容。