Returns: An
exception_ptr object that refers to the
currently handled exception
or a copy of the currently
handled exception, or a null
exception_ptr object if no exception is being
handled
. The referenced object shall remain valid at least as long as there is an
exception_ptr object that refers to it
. If the function needs to allocate memory and the attempt fails, it returns an
exception_ptr object that refers to an instance of
bad_alloc. It is unspecified whether the return values of two successive calls to
current_exception refer to the same exception object
. [
Note 3:
That is, it is unspecified whether
current_exception
creates a new copy each time it is called
. —
end note]
If the attempt to copy the current exception object throws an exception, the function
returns an
exception_ptr object that refers to the thrown exception or,
if this is not possible, to an instance of
bad_exception. [
Note 4:
The
copy constructor of the thrown exception can also fail, so the implementation is allowed
to substitute a
bad_exception object to avoid infinite
recursion
. —
end note]