且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

标记为noexcept的函数中是否有异常?

更新时间:2023-11-30 18:52:10

是的,这是完全合法的,只要异常不漏出函数。

Yes, this is perfectly legal, as long as the exception doesn't leak out of the function.


一个实现不应该拒绝一个表达式,只是因为执行时它抛出或可能抛出
一个异常,函数不允许。

An implementation shall not reject an expression merely because when executed it throws or might throw an exception that the containing function does not allow.

[C ++ 11中的except.spec / 11]

[except.spec/11 in C++11]