When the throw expression evaluates, the exception object is initialized from the value of the expression. The highlighted exception object gets its type from the static type of the throw expression, ignoring any const and volatile qualifiers. For class types, this means that copy initialization is in progress.
The object of the object of exceptions goes beyond the area in which the throw occurs. Think of it as living in a special exclusion zone on one side of a regular call stack where local objects live.
Inside the catch name initialized by the infected exception object is initialized by this exception object, and not by the throw argument, even if this value was lvalue.
If you catch through a non-const reference, you can mutate the exception object, but not from what it was initialized. You can change the behavior of the program if you re-select the exception in ways that you would not be able to if you caught by value or constant link ( const_cast to the side).
The exception object is destroyed when the last catch block completes, which does not exit through the second throw (i.e., an indifferent expression of the expression of the throw).
Charles Bailey Oct 31 '09 at 12:03 2009-10-31 12:03
source share