任何人都可以向我解释C ++异常规范吗? [英] Can anyone explain C++ exception specifications to me?

查看:133
本文介绍了任何人都可以向我解释C ++异常规范吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以解释在C ++中使用的异常规范?

Can anyone explain Exception Specifications as used in C++ ?


  • 什么时候使用(我很少看到它在代码中使用) / li>
  • 使用异常规范的利弊(利弊)是什么?

推荐答案

它们何时使用(我很少看到它在代码中使用)

希望永远不会在下一个C ++版本中被弃用

When are they used (I have rarely seen it used in code)
Hopefully never as they are deprecated in the next version of C++ due for standardization next year.

使用异常规范的优点和缺点(优点/缺点)是什么?

它们为你的代码的读者提供了一种方法来准确地知道函数允许抛出什么异常。问题是,如果抛出了意外的异常(规范中没有),程序将被终止(默认)。

What are the pros and cons (benefits/disadvantages) of using exception specifications?
They provide a way for readers of your code to know exactly what exceptions a function is allowed to throw. The problem is, that if an unexpected exception (one not in the specification) is thrown, then the program will be terminated (by default).

这篇关于任何人都可以向我解释C ++异常规范吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆