限制C ++函数允许的throws有什么好处? [英] What is the benefit to limiting throws allowed by a C++ function?

查看:272
本文介绍了限制C ++函数允许的throws有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从C ++函数声明可能的异常抛出的好处是什么?换句话说,添加关键字 throw()实际上是做什么的?

What is the benefit of declaring the possible exception-throws from a C++ function? In other words, what does adding the keyword throw() actually do?

声明例如 void do_something()throw(); 应该保证没有异常从 do_something()然而,这似乎不适用于 do_something()中调用的函数,因此这是一个弱的保证。

I've read that a function declaration such as void do_something() throw(); should guarantee that no exceptions originate from the do_something() function; however, this doesn't seem to hold true of functions called within do_something(), thus making it a weak guarantee.

请概述此语言功能的实用性(和最佳用例)。

Please outline the usefulness (and best-use cases) of this language feature.

推荐答案

Sutter

http://www.ddj.com/architect/184401544

简短版本为


  1. / li>
  2. 除非可能为空。

这篇关于限制C ++函数允许的throws有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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