std::chrono::nonexistent_local_time
來自 cppreference.com
定義於標頭檔案 <chrono> |
||
class nonexistent_local_time; |
(C++20 起) | |
定義一種物件型別,當嘗試將不存在的 std::chrono::local_time 轉換為 std::chrono::sys_time 而未指定 std::chrono::choose (例如 choose::earliest
或 choose::latest
) 時,作為異常丟擲。
此異常由 std::chrono::time_zone::to_sys 以及呼叫它的函式(例如接受 std::chrono::local_time 的 std::chrono::zoned_time 的建構函式)丟擲。
繼承圖
目錄 |
[編輯] 成員函式
(建構函式) |
構造異常物件 (公開成員函式) |
運算子= (operator=) |
替換異常物件 (公開成員函式) |
what |
返回解釋字串 (公開成員函式) |
std::chrono::nonexistent_local_time::nonexistent_local_time
template< class Duration > nonexistent_local_time( const std::chrono::local_time<Duration>& tp, |
(1) | (C++20 起) |
nonexistent_local_time( const nonexistent_local_time& other ) noexcept; |
(2) | (C++20 起) |
構造異常物件。
1)
what()
返回的解釋性字串等同於以下程式碼產生的 os.str()
:std::ostringstream os; os << tp << " is in a gap between\n" << std::chrono::local_seconds(i.first.end.time_since_epoch()) + i.first.offset << ' ' << i.first.abbrev << " and\n" << std::chrono::local_seconds(i.second.begin.time_since_epoch()) + i.second.offset << ' ' << i.second.abbrev << " which are both equivalent to\n" << i.first.end << " UTC";
如果 i.result != std::chrono::local_info::nonexistent,則行為未定義。
2) 複製建構函式。如果 *this 和 other 都具有動態型別
std::chrono::nonexistent_local_time
,則 std::strcmp(what(), other.what()) == 0。引數
tp | - | 嘗試轉換的時間點 |
i | - | 描述轉換嘗試結果的 std::chrono::local_info |
其他 | - | 另一個 nonexistent_local_time 物件,用於複製 |
異常
可能丟擲 std::bad_alloc
注意
由於複製標準庫中派生自 std::exception
的類不允許丟擲異常,因此此訊息通常在內部儲存為單獨分配的引用計數字符串。
std::chrono::nonexistent_locale_time::operator=
nonexistent_locale_time& operator=( const nonexistent_locale_time& other ) noexcept; |
(C++20 起) | |
將內容賦值為 other 的內容。如果 *this 和 other 都具有動態型別 std::chrono::nonexistent_locale_time
,則賦值後 std::strcmp(what(), other.what()) == 0。
引數
其他 | - | 用於賦值的另一個異常物件 |
返回值
*this
std::chrono::nonexistent_locale_time::what
virtual const char* what() const noexcept; |
(C++20 起) | |
返回解釋字串。
返回值
指向一個實現定義的以空字元結尾的字串,其中包含解釋性資訊。該字串適合轉換為 std::wstring 並顯示。該指標保證在獲取它的異常物件被銷燬之前,或在異常物件上的非 const 成員函式(例如複製賦值運算子)被呼叫之前有效。
在常量求值期間,返回的字串使用普通字面量編碼進行編碼。 |
(C++26 起) |
注意
允許但不要求實現重寫 what()
。
繼承自 std::exception
成員函式
[虛擬函式] |
銷燬異常物件 ( std::exception 的虛公共成員函式) |
[虛擬函式] |
返回解釋字串 ( std::exception 的虛公共成員函式) |
[編輯] 參閱
報告本地時間模糊時丟擲的異常 (類) |