std:: vformat_to
|
定义于头文件
<format>
|
||
|
template
<
class
OutputIt
>
OutputIt vformat_to ( OutputIt out, std:: string_view fmt, std:: format_args args ) ; |
(1) | (C++20 起) |
|
template
<
class
OutputIt
>
OutputIt vformat_to ( OutputIt out, std:: wstring_view fmt, std:: wformat_args args ) ; |
(2) | (C++20 起) |
|
template
<
class
OutputIt
>
OutputIt vformat_to
(
OutputIt out,
const
std::
locale
&
loc,
|
(3) | (C++20 起) |
|
template
<
class
OutputIt
>
OutputIt vformat_to
(
OutputIt out,
const
std::
locale
&
loc,
|
(4) | (C++20 起) |
根据格式字符串 fmt 格式化 args 所持有的参数,并将结果写入输出迭代器 out 。如果存在 loc ,则将其用于区域设置特定的格式化。
令
CharT
为
decltype
(
fmt
)
::
char_type
(对于重载
(1,3)
为
char
,对于重载
(2,4)
为
wchar_t
)。
这些重载仅当
OutputIt
满足概念
std::
output_iterator
<
const
CharT
&
>
时参与重载决议。
OutputIt
必须满足
std::
output_iterator
<
const
CharT
&
>
概念(符合其语义要求),且对于参数类型中的任意
Ti
,
std::
formatter
<
Ti, CharT
>
必须满足
Formatter
要求。否则行为未定义。
目录 |
参数
| out | - | 输出缓冲区的迭代器 | ||||||||||||||||||||||||||||||||||||||||||||||
| fmt | - |
表示格式字符串的对象。格式字符串包含:
每个替换字段具有以下格式:
1)
不带格式说明的替换字段
2)
带格式说明的替换字段
|
||||||||||||||||||||||||||||||||||||||||||||||
| args | - | 要格式化的参数 | ||||||||||||||||||||||||||||||||||||||||||||||
| loc | - | 用于本地化特定格式化的 std::locale | ||||||||||||||||||||||||||||||||||||||||||||||
返回值
输出范围末尾之后的迭代器。
异常
当 fmt 不是有效格式字符串时抛出 std::format_error 。同时会传播由格式化器或迭代器操作抛出的任何异常。
示例
|
本节内容不完整
原因:缺少示例 |
缺陷报告
以下行为变更缺陷报告被追溯应用于先前发布的C++标准。
| 缺陷报告 | 适用范围 | 发布时行为 | 正确行为 |
|---|---|---|---|
| P2216R3 | C++20 |
args
的类型基于
OutputIt
参数化
|
不进行参数化 |