標準庫標頭檔案 <exception>
來自 cppreference.com
此標頭檔案是錯誤處理庫的一部分。
型別 | ||
標準庫元件丟擲的異常的基類 (類) | ||
(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); }