std::vformat_to
来自cppreference.com
| 在标头 <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 ,对重载 wchar_t 为 (2,4) )。
这些重载只有在 OutputIt 满足概念 std::output_iterator<const CharT&> 时才参与重载决议。若 OutputIt 不实现(满足其语义要求)概念 std::output_iterator<const CharT&> ,或若对 Args 中任何 Ti , std::formatter<Ti, CharT> 不满足格式化器 (Formatter) 要求则行为未定义。
参数
| out | - | 指向输出缓冲区的迭代器 |
| fmt | - |
每个替换域拥有下列格式:
arg-id 指定用于格式化其值的 格式说明由对应参数特化的 std::formatter 定义。
|
| args... | - | 要格式化的参数 |
| loc | - | 用于本地环境特定的格式化的 std::locale |
返回值
输出范围末尾后一位置的迭代器。
异常
若 fmt 对于提供的参数不是合法的格式字符串则抛出 std::format_error 。并且会传播格式化器或迭代器操作所抛的任何异常。
示例
| 本节未完成 原因:暂无示例 |
缺陷报告
下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。
| 缺陷报告 | 应用于 | 出版时的行为 | 正确行为 |
|---|---|---|---|
| P2216R3 | C++20 | args 的类型在 OutputIt 上参数化
|
不参数化 |