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

后端 未结 7 1275
独厮守ぢ
独厮守ぢ 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:21

    You would have to guarantee that the destructor is not being called, because of another exception.

    That being said I don't use exceptions. But if I was compelled to use them to keep my job, I'd never throw an exception from a destructor.

提交回复
热议问题