std::chrono::operator<<(std::chrono::month)
来自cppreference.com
在标头 <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,它由以与 os 关联的本地环境所确定的 m 所表示的月的缩写月名组成,并将 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 的格式化支持 (类模板特化) |