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

定义于头文件 <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 中。这首先构成由格式为 yyyy-mm-dd (同 formatter 用 %F 说明符的输出)的日期文本表示组成的 std::basic_string<CharT> s 。然后,若 !ymd.ok() 则后附 " is not a valid date"s 。插入 sos 中。

等价于

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

其中 STATICALLY_WIDEN<CharT>("...")CharTchar 则为 "..." ,而若 CharTwchar_t 则为 L"..."

返回值

os

参阅

(C++20)
在新 string 中存储参数的格式化表示
(函数模板)
std::formatter 的特化,按照提供的格式格式化 year_month_day
(类模板特化)