共用方式為


<exception>

定義數個與例外狀況處理有關的類型和函式。 在系統可從錯誤復原的情況下,使用例外狀況處理。 它提供方式,將控制從函式傳回至程式。 併入例外狀況處理的目標是增加程式穩定性,同時以有次序的方式從錯誤復原。

需求

標頭: < exception>

命名空間:std

成員

Typedefs

名稱 描述
exception_ptr 描述例外狀況指標的類型。
terminate_handler 類型,描述適合做為 terminate_handler 之函式的指標。
unexpected_handler 類型,描述適合做為 unexpected_handler 之函式的指標。

函式

名稱 描述
current_exception 取得目前例外狀況的指標。
get_terminate 取得目前的 terminate_handler 函式。
get_unexpected 取得目前的 unexpected_handler 函式。
make_exception_ptr 建立持有例外狀況複本的 exception_ptr 物件。
rethrow_exception 擲回做為參數傳遞的例外狀況。
rethrow_if_nested 如果巢狀,則轉換和擲回例外狀況。
set_terminate 建立新 terminate_handler,在程式終止時呼叫。
set_unexpected 建立新的 unexpected_handler,當未預期的例外狀況發生時擲回。
terminate 呼叫終止處理常式。
throw_with_nested 如果巢狀,則擲回例外狀況。
uncaught_exception 只有當系統正在處理擲回的例外狀況時,才傳回 true
unexpected 呼叫未預期的處理常式。

類別

名稱 描述
bad_exception 類別 此類別描述從 unexpected_handler 所擲回的例外狀況。
exception 類別 此類別可作為特定運算式和 C++ 標準程式庫所擲回之所有例外狀況的基底類別。
nested_exception 類別 類別描述可以擷取並儲存以供日後使用的例外狀況。

另請參閱

標頭檔參考
C++ 標準程式庫中的執行緒安全