Throwing exceptions
From cppreference.com
Throwing an exception transfers control to a handler.
An exception can be thrown from throw expressions, the following contexts may also throw exceptions:
Contents |
[edit] Exception object
Throwing an exception initializes an object with dynamic storage duration, called the exception object.
If the type of the exception object would be one of the following types, the program is ill-formed:
- an incomplete type
- an abstract class type
- a pointer to an incomplete type other than (possibly cv-qualified) void
[edit] Constructing and destructing exception objects
Given the type of the exception object as T
:
- Let obj be an lvalue of type const T, the copy-initialization of an object of type
T
from obj must be well-formed. - If
T
is a class type:
- The selected constructor is odr-used.
- The destructor of
T
is