std::chrono::operator<<(std::chrono::year_month_day)
来自cppreference.com
< cpp | chrono | year month day
| 在标头 <chrono> 定义
|
||
| template< class CharT, class Traits > std::basic_ostream<CharT, Traits>& |
(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(os.getloc(), STATICALLY_WIDEN<CharT>("{:%F}"), ymd) :
std::format(os.getloc(), STATICALLY_WIDEN<CharT>("{:%F} is not a valid date"), ymd));
其中 STATICALLY_WIDEN<CharT>("...") 当 CharT 为 char 时为 "...",而当 CharT 为 wchar_t 时为 L"..."。
返回值
os
示例
| 本节未完成 原因:暂无示例 |
参阅
| (C++20) |
在新字符串中存储参数的格式化表示 (函数模板) |
year_month_day 的格式化支持 (类模板特化) |