std::chrono::operator<<(std::chrono::month)
来自 cppreference.cn
定义于头文件 <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 的格式化支持(类模板特化) |