on-internet
← Community

If you shouldn't throw exceptions in a destructor, how do you handle errors in it?

Stack Overflow ·

Most people say never throw an exception out of a destructor - doing so results in undefined behavior. Stroustrup makes the point that "the vector destructor explicitly invokes the destructor for every element. This implies that if an element destructor throws, the vector destruction fails... There is really no good way to protect against exceptions thrown from destructors, so the library makes no guarantees if an element destructor throws" (from Appendix E3.2). This article seems to say otherwise - that throwing destructors are more or less okay. So my question is this - if throwing from a de

Comments

Sign in or sign up to comment and upvote.

No comments yet.