std::vformat_to
来自 cppreference.cn
定义于头文件 <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&>,并且 std::formatter<Ti, CharT> 必须满足任何参数类型 Ti
的 Formatter 要求。否则,行为未定义。
内容 |
[编辑] 参数
out | - | 输出缓冲区的迭代器 | ||||||||||||||||||||||||||||||||||||||||||||||
fmt | - | 表示格式字符串的对象。格式字符串由以下内容组成:
每个替换字段具有以下格式
1) 没有格式规范的替换字段
2) 带有格式规范的替换字段
| ||||||||||||||||||||||||||||||||||||||||||||||
args | - | 要格式化的参数 | ||||||||||||||||||||||||||||||||||||||||||||||
loc | - | 用于特定于区域设置的格式化的 std::locale |
[编辑] 返回值
超出输出范围末端的迭代器。
[编辑] 异常
如果 fmt 不是提供参数的有效格式字符串,则抛出 std::format_error。 也会传播格式化程序或迭代器操作抛出的任何异常。
[编辑] 示例
本节不完整 原因:没有示例 |
[编辑] 缺陷报告
以下行为变更缺陷报告已追溯应用于先前发布的 C++ 标准。
DR | 应用于 | 已发布行为 | 正确行为 |
---|---|---|---|
P2216R3 | C++20 | args 的类型在 OutputIt 上参数化 | 未参数化 |