std::chrono:: operator<< (std::chrono::month)
|
定义于头文件
<chrono>
|
||
|
template
<
class
CharT,
class
Traits
>
std::
basic_ostream
<
CharT, Traits
>
&
|
(C++20 起) | |
如果 ! m. ok ( ) ,则向 os 插入 unsigned ( m ) 后接 " is not a valid month" 。否则,构造一个 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
>
(
"{} 不是有效的月份"
)
,
unsigned
(
m
)
)
)
;
其中
STATICALLY_WIDEN
<
CharT
>
(
"..."
)
当
CharT
为
char
时是
"..."
,当
CharT
为
wchar_t
时是
L
"..."
。
目录 |
返回值
os
注释
此 operator << 主要用于调试用途。如需精确控制格式化,请使用 std::format 。
缺陷报告
以下行为变更缺陷报告被追溯应用于先前发布的C++标准。
| 缺陷报告 | 适用范围 | 发布时行为 | 正确行为 |
|---|---|---|---|
| P2372R3 | C++20 | 默认使用给定的区域设置 |
需要使用
L
前缀来使用给定的区域设置
|
参见
|
(C++20)
|
将参数的格式化表示存储到新字符串中
(函数模板) |
month
的格式化支持
(类模板特化) |