æ ååºæ 头 <exception>
æ¥èªcppreference.com
æ¤å¤´æä»¶æ¯é误å¤çåºçä¸é¨åã
ç±» | ||
æ ååºç»ä»¶æåºçåç§å¼å¸¸çåºç±» (ç±») | ||
(C++11) |
ç¨äºæè·å¹¶åå¨å½åå¼å¸¸çæ··å
¥ç±»å (ç±») | |
å½ std::current_exception æ æ³å¤å¶å¼å¸¸å¯¹è±¡æ¶æåºçå¼å¸¸ (ç±») | ||
(C++17 ä¸ç§»é¤) |
std::unexpected æè°ç¨ç彿°ç±»å (typedef) | |
std::terminate æè°ç¨ç彿°ç±»å (typedef) | ||
(C++11) |
ç¨äºå¤çå¼å¸¸å¯¹è±¡çå
±äº«æéç±»å (typedef) | |
彿° | ||
(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++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 = /* æªææ */; 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: // ç¹æ®æå彿°çè§å®è§ [exception] 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; // 访é®å½æ° [[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); }