std::basic_format_args_C++中文网
| 定义于头文件 |
||
| template<class Context> |
(1) | (C++20 起) |
| using format_args = basic_format_args<std::format_context>; |
(2) | (C++20 起) |
| using wformat_args = basic_format_args<std::wformat_context>; |
(3) | (C++20 起) |
| template<class OutputIt, class CharT> |
(4) | (C++20 起) |
提供到格式化参数的访问。
成员函数
构造 basic_format_args 对象 (公开成员函数) | |
| 返回位于给定下标的格式化参数 (公开成员函数) |
std::basic_format_args::basic_format_args
| basic_format_args() noexcept; |
(1) | |
| template<class... Args> |
(2) | |
1) 构造不保有任何格式化参数的 basic_format_args 对象。
2) 从调用 std::make_format_args 或 std::make_wformat_args 的结果构造 basic_format_args 对象。
std::basic_format_args 拥有引用语义。程序员负责确保 *this 不会比 store 活得更久(从而不应比 std::make_format_args 或 std::make_wformat_args 的参数存活更久)。
std::basic_format_args::get
| std::basic_format_arg<Context> get(std::size_t i) const noexcept; |
||
返回保有 args 中第 i 参数的 std::basic_format_arg ,其中 args 是传递给 std::make_format_args 或 std::make_wformat_args 的形参包。
若无足够的参数(即 *this 为默认构造或 i 不小于格式化参数数),则返回默认构造的 std::basic_format_arg (保有 std::monostate 对象)。