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,對於過載 (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 進行引數化 |
不引數化 |