什么时候可以从C ++中的析构函数抛出异常? [英] When is it OK to throw an exception from a destructor in C++?

查看:153
本文介绍了什么时候可以从C ++中的析构函数抛出异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道规则是在析构函数中不要抛出一个规则,我明白为什么。我不敢做但是即使是C ++ Faq Lite,这个规则也是99%的时间。他们未能深入研究的其他1%是什么?



链接到〜()中的C ++ Faq Lite项目符号点:

解决方案

只是不要这样做。
如果星星和行星按照您需要的方式对齐...



仍然不要这样做。


I know the rule is to NEVER throw one during a destructor, and I understand why. I would not dare do it. But even the C++ Faq Lite says that this rule is good 99% of the time. What is the other 1% that they fail to delve into?

Link to the C++ Faq Lite bullet point on throwing from ~():

解决方案

Just don't do it. If the stars and planets align in such a way that you find you need to...

Still don't do it.

这篇关于什么时候可以从C ++中的析构函数抛出异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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