When is it OK to throw an exception from a destructor in C++?

后端 未结 7 1165
独厮守ぢ
独厮守ぢ 2020-12-16 23:33

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 tim

相关标签:
7条回答
  • 2020-12-17 00:29

    If the destruction is part of a controlled process, then it would be acceptable, but still, you need to get rid of remaining references as much as possible, so throwing might not be good.

    Destruction can happen implicitely so often that a throw might break the normal code logic.

    0 讨论(0)
提交回复
热议问题