Documentation Home >> Headers >> <exception_ptr> Header >> std::current_exception Function

Take a copy of the exception currently being handled in the innermost enclosing catch block, and store it in an instance of std::exception_ptr.

std::exception_ptr current_exception();

Returns:

If an exception is currently being handled, then an std::exception_ptr instance that refers to that exception, otherwise a default-constructed std::exception_ptr instance. If memory must be allocated for the stored exception, and the attempt to allocate memory fails, then the result is an std::exception_ptr instance that refers to an exception of type std::bad_alloc. If the exception must be copied, and the copy-constructor of the currently-handled exception throws another exception then either an std::exception_ptr object that references that exception or an std::exception_ptr object that references an exception of type std::bad_exception shall be returned.

Throws:

Nothing.

Header

#include <exception_ptr>

See Also