std::current_exception (3) - Linux Man Pages
Defined in header <exception>
std::exception_ptr current_exception() noexcept; (since C++11)
If called during exception handling (typically, in a catch clause), captures the current exception object and creates an std::exception_ptr that holds either a copy or a reference to that exception object (depending on the implementation). The referenced object remains valid at least as long as there is an exception_ptr object that refers to it.
If the implementation of this function requires a call to new and the call fails, the returned pointer will hold a reference to an instance of std::bad_alloc.
If the implementation of this function requires copying the captured exception object and its copy constructor throws an exception, the returned pointer will hold a reference to the exception thrown. If the copy constructor of the thrown exception object also throws, the returned pointer may hold a reference to an instance of std::bad_exception to break the endless loop.
If the function is called when no exception is being handled, an empty std::exception_ptr is returned.
An instance of std::exception_ptr holding a reference to the exception object, or a copy of the exception object, or to an instance of std::bad_alloc or to an instance of std::bad_exception.
// Run this code
exception_ptr shared pointer type for handling exception objects
rethrow_exception throws the exception from an std::exception_ptr
make_exception_ptr creates an std::exception_ptr from an exception object