名稱空間
變體
操作

std::chrono::operator<<(std::chrono::year_month_day)

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

std::basic_ostream<CharT, Traits>&
    operator<<( std::basic_ostream<CharT, Traits>& os,

                const std::chrono::year_month_day& ymd );
(C++20 起)

ymd 的文字表示輸出到流 os。首先形成一個 std::basic_string<CharT> s,其中包含日期以 yyyy-mm-dd 格式(與 formatter 使用 %F 格式說明符輸出的格式相同)的文字表示。然後,如果 !ymd.ok(),則將 " is not a valid date" 附加到 s。將 s 插入到 os 中。

等價於

return os << (ymd.ok() ?
    std::format(STATICALLY_WIDEN<CharT>("{:%F}"), ymd) :
    std::format(STATICALLY_WIDEN<CharT>("{:%F} is not a valid date"), ymd));

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

[編輯] 返回值

os

[編輯] 示例

[編輯] 參閱

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