gpt4 book ai didi

c++ - 定义重复的异常规范是否合法

转载 作者:行者123 更新时间:2023-11-30 00:58:00 24 4
gpt4 key购买 nike

void FooThrow()  throw(string, string)
{
}

我在g++ 4.4.3 中编译了上面的代码,没有任何错误。但是,我不确定这是否是基于标准的合法语法。

最佳答案

在 C++03 中,15.4.6:

An exception-specification can include the same type more than once [...] even though doing so is redundant.

标准总是在异常规范中提及类型的,这肯定是故意的。

我会疏忽指出 Herb Sutter 的 article ,最好总结为,

# Don't use exception specifications.

关于c++ - 定义重复的异常规范是否合法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7060930/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com