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++ 标准。
缺陷报告 | 应用于 | 发布时的行为 | 正确的行为 |
---|---|---|---|
P2216R3 | C++20 | args 的类型根据 OutputIt 进行参数化 |
不参数化 |