std::chrono::operator<<(std::chrono::month)
來自 cppreference.com
定義於標頭檔案 <chrono> |
||
template< class CharT, class Traits > std::basic_ostream<CharT, Traits>& |
(C++20 起) | |
如果 !m.ok(),則將 unsigned(m) 後跟 " is not a valid month" 插入到 os。否則,形成一個 std::basic_string<CharT> s,它由 m 所代表月份的縮寫月份名稱組成,該名稱使用與 os 相關聯的語言環境確定,並將 s 插入到 os 中。
等價於
return os << (m.ok() ?
std::format(os.getloc(), STATICALLY_WIDEN<CharT>("{:L%b}"), m) :
std::format(os.getloc(), STATICALLY_WIDEN<CharT>("{} is not a valid month"), unsigned(m)));
其中 STATICALLY_WIDEN<CharT>("...") 如果 CharT
是 char,則為 "...",如果 CharT
是 wchar_t,則為 L"..."。
目錄 |
[編輯] 返回值
os
[編輯] 注意
此 operator<< 主要用於除錯。如需控制格式化,請使用 std::format。
[編輯] 缺陷報告
下列更改行為的缺陷報告追溯地應用於以前出版的 C++ 標準。
缺陷報告 | 應用於 | 釋出時的行為 | 正確的行為 |
---|---|---|---|
P2372R3 | C++20 | 預設使用給定區域設定 | 需要 L 才能使用給定區域設定 |
[編輯] 參閱
(C++20) |
將引數的格式化表示儲存在新字串中 (函式模板) |
month 的格式化支援(類模板特化) |