Provides consistent interface to handle errors through the throw expression. All exceptions generated by the standard library inherit from std::exception. All member functions of std::exception are constexpr.
Notes Because copying std::exception is not permitted to throw exceptions, when derived classes (such as std::runtime_error) have to manage a user-defined diagnostic message, it is typically implemented as a copy-on-write string.
Exception handling provides a way of transferring control and information from some point in the execution of a program to a handler associated with a point previously passed by the execution (in other words, exception handling transfers control up the call stack). Evaluating a throw expression will throw an exception.
Types exception base class for exceptions thrown by the standard library components (class) [edit] nested_exception (C++11) a mixin type to capture and store current exceptions (class) [edit] bad_exceptionexception thrown when std::current_exception fails to copy the exception object (class) [edit] unexpected_handler (deprecated in C++11)(removed in C++17) the type of the function called by ...
Pointer to a null-terminated string with explanatory information. The pointer is guaranteed to be valid at least until the exception object from which it is obtained is destroyed, or until a non-const member function on the exception object is called. The returned string is encoded with the ordinary literal encoding during constant evaluation.
Handling exceptions When an exception is thrown, control is transferred to the nearest handler with a matching type; “nearest” means the handler for which the compound statement or the member initializer list (if present) following the try keyword was most recently entered by the thread of control and not yet exited.
1) Detects if the current thread has a live exception object, that is, an exception has been thrown or rethrown and not yet entered a matching catch clause, std::terminate or std::unexpected. In other words, std::uncaught_exception detects if stack unwinding is currently in progress.
std::exception_ptr is a nullable pointer-like type that manages an exception object which has been thrown and captured with std::current_exception. An instance of std::exception_ptr may be passed to another function, possibly on another thread, where the exception may be rethrown and handled with a catch clause.