名稱空間
變體
操作

std::chrono::operator<<(std::chrono::weekday)

來自 cppreference.com
< cpp‎ | chrono‎ | weekday
 
 
 
 
定義於標頭檔案 <chrono>
template< class CharT, class Traits >

std::basic_ostream<CharT, Traits>&

    operator<<( std::basic_ostream<CharT, Traits>& os, const std::chrono::weekday& wd );
(C++20 起)

如果 !wd.ok() 為真,則將 wd.c_encoding() 後跟 " is not a valid weekday" 插入到 os 中。否則,根據與 os 關聯的區域設定,形成一個包含 wd 所代表的星期幾的縮寫名稱的 std::basic_string<CharT> 字串 s,並將其插入到 os 中。

等價於

return os << (wd.ok() ?
    std::format(os.getloc(), STATICALLY_WIDEN<CharT>("{:L%a}"), wd) :
    std::format(os.getloc(), STATICALLY_WIDEN<CharT>("{} is not a valid weekday"),
                wd.c_encoding()));

其中 STATICALLY_WIDEN<CharT>("...") 如果 CharTchar 則為 "...",如果 CharTwchar_t 則為 L"..."

目錄

[編輯] 返回值

os

[編輯] 示例

[編輯] 缺陷報告

下列更改行為的缺陷報告追溯地應用於以前出版的 C++ 標準。

缺陷報告 應用於 釋出時的行為 正確的行為
P2372R3 C++20 預設使用給定區域設定 需要 L 才能使用給定區域設定

[編輯] 參閱

(C++20)
將引數的格式化表示儲存在新字串中
(函式模板) [編輯]
weekday 的格式化支援
(類模板特化) [編輯]