Are destructors called after a throw in C++?
问题 I ran a sample program and indeed destructors for stack-allocated objects are called, but is this guaranteed by the standard? 回答1: Yes, it is guaranteed (provided the exception is caught), down to the order in which the destructors are invoked: C++11 15.2 Constructors and destructors [except.ctor] 1 As control passes from a throw-expression to a handler, destructors are invoked for all automatic objects constructed since the try block was entered. The automatic objects are destroyed in the