std::experimental::bad_any_cast
來自 cppreference.com
< cpp | experimental | any
定義於標頭檔案 <experimental/any> |
||
class bad_any_cast : public std::bad_cast; |
(庫基礎 TS) | |
定義了一個物件型別,當 std::experimental::any_cast 的值返回形式失敗時丟擲。
目錄 |
[編輯] 成員函式
(建構函式) |
構造一個新的 bad_any_cast 物件(公開成員函式) |
operator= |
替換 bad_any_cast 物件(公開成員函式) |
what |
返回解釋字串 (公開成員函式) |
std::experimental::bad_any_cast::bad_any_cast
bad_any_cast() noexcept; |
(1) | (庫基礎 TS) |
bad_any_cast( const bad_any_cast& other ) noexcept; |
(2) | (庫基礎 TS) |
構造一個新的 bad_any_cast
物件,帶有一個實現定義的以空字元結尾的位元組字串,該字串可透過 what() 訪問。
1) 預設建構函式。
2) 複製建構函式。如果 *this 和 other 都具有動態型別
std::experimental::bad_any_cast
,則 std::strcmp(what(), other.what()) == 0。引數
其他 | - | 要複製的另一個異常物件 |
std::experimental::bad_any_cast::operator=
bad_any_cast& operator=( const bad_any_cast& other ) noexcept; |
(庫基礎 TS) | |
將內容賦值為 other 的內容。如果 *this 和 other 都具有動態型別 std::experimental::bad_any_cast
,則賦值後 std::strcmp(what(), other.what()) == 0。
引數
其他 | - | 用於賦值的另一個異常物件 |
返回值
*this
std::experimental::bad_any_cast::what
virtual const char* what() const noexcept; |
(庫基礎 TS) | |
返回解釋字串。
返回值
指向一個實現定義的以空字元結尾的字串的指標,包含解釋性資訊。該字串適合轉換為 std::wstring 並顯示。該指標保證至少在獲取它的異常物件被銷燬之前或在異常物件上呼叫非 const 成員函式(例如複製賦值運算子)之前有效。
在常量求值期間,返回的字串使用普通字面量編碼進行編碼。 |
(C++26 起) |
注意
允許但不要求實現重寫 what()
。
繼承自 std::bad_cast
繼承自 std::exception
成員函式
[虛擬函式] |
銷燬異常物件 ( std::exception 的虛公共成員函式) |
[虛擬函式] |
返回解釋字串 ( std::exception 的虛公共成員函式) |