标准库头文件 <exception>
来自 cppreference.cn
此头文件是错误处理库的一部分。
类型 | ||
标准库组件抛出的异常的基类 (类) | ||
(C++11) |
用于捕获和存储当前异常的 mixin 类型 (类) | |
当 std::current_exception 无法复制异常对象时抛出的异常 (类) | ||
(C++11 中已废弃)(C++17 中已移除) |
由 std::unexpected 调用的函数类型 (类型定义) | |
由 std::terminate 调用的函数类型 (类型定义) | ||
(C++11) |
用于处理异常对象的共享指针类型 (类型定义) | |
函数 | ||
(C++11 中已废弃)(C++17 中已移除) |
动态异常规范被违反时调用的函数 (函数) | |
(C++20 中移除*)(C++17) |
检查当前是否正在进行异常处理 (函数) | |
(C++11) |
从异常对象创建 std::exception_ptr (函数模板) | |
(C++11) |
将当前异常捕获到 std::exception_ptr 中 (函数) | |
(C++11) |
从 std::exception_ptr 抛出异常 (函数) | |
(C++11) |
抛出其参数并混入 std::nested_exception (函数模板) | |
(C++11) |
从 std::nested_exception 抛出异常 (函数模板) | |
异常处理失败时调用的函数 (函数) | ||
(C++11) |
获取当前的 terminate_handler (函数) | |
更改 std::terminate 将调用的函数 (函数) | ||
(C++11 中已废弃)(C++17 中已移除) |
获取当前的 unexpected_handler (函数) | |
(C++11 中已废弃)(C++17 中已移除) |
更改 std::unexpected 将调用的函数 (函数) |
[编辑] 概要
namespace std { class exception; class bad_exception; class nested_exception; using terminate_handler = void (*)(); terminate_handler get_terminate() noexcept; terminate_handler set_terminate(terminate_handler f) noexcept; [[noreturn]] void terminate() noexcept; int uncaught_exceptions() noexcept; using exception_ptr = /* unspecified */; exception_ptr current_exception() noexcept; [[noreturn]] void rethrow_exception(exception_ptr p); template<class E> exception_ptr make_exception_ptr(E e) noexcept; template<class T> [[noreturn]] void throw_with_nested(T&& t); template<class E> void rethrow_if_nested(const E& e); }
[编辑] 类 std::exception
namespace std { class exception { public: exception() noexcept; exception(const exception&) noexcept; exception& operator=(const exception&) noexcept; virtual ~exception(); virtual const char* what() const noexcept; }; }
[编辑] 类 std::bad_exception
namespace std { class bad_exception : public exception { public: // see [exception] for the specification of the special member functions const char* what() const noexcept override; }; }
[编辑] 类 std::nested_exception
namespace std { class nested_exception { public: nested_exception() noexcept; nested_exception(const nested_exception&) noexcept = default; nested_exception& operator=(const nested_exception&) noexcept = default; virtual ~nested_exception() = default; // access functions [[noreturn]] void rethrow_nested() const; exception_ptr nested_ptr() const noexcept; }; template<class T> [[noreturn]] void throw_with_nested(T&& t); template<class E> void rethrow_if_nested(const E& e); }