std::vformat
来自cppreference.com
| 定义于头文件 <format>
|
||
| std::string vformat(std::string_view fmt, std::format_args args); |
(1) | (C++20 起) |
| std::wstring vformat(std::wstring_view fmt, std::wformat_args args); |
(2) | (C++20 起) |
| std::string vformat(const std::locale& loc, std::string_view fmt, std::format_args args); |
(3) | (C++20 起) |
| std::wstring vformat(const std::locale& loc, std::wstring_view fmt, std::wformat_args args); |
(4) | (C++20 起) |
按照格式字符串 fmt 格式化 args ,并返回作为 string 的结果。 loc 若存在,则用于本地环境特定的格式化。
参数
| fmt | - | 表示格式字符串的字符串视图。
每个替换域拥有下列格式:
arg-id 指定用于格式化其值的 格式说明由对应参数特化的 std::formatter 定义。
|
| args... | - | 要格式化的参数 |
| loc | - | 用于本地环境特定格式化的 std::locale |
返回值
保有格式化结果的 string 对象。
异常
若 fmt 对于提供的参数不是合法的格式字符串则抛出 std::format_error 。并且会传播格式化器或迭代器操作所抛的任何异常。
示例
| 本节未完成 原因:暂无示例 |