C++
语言
标准库头文件
自立与有宿主实现
具名要求
语言支持库
概念库 (C++20)
诊断库
工具库
字符串库
容器库
迭代器库
范围库 (C++20)
算法库
数值库
本地化库
输入/输出库
文件系统库 (C++17)
正则表达式库 (C++11)
原子操作库 (C++11)
线程支持库 (C++11)
技术规范
标准库头文件
语言支持
概念
诊断
通用工具
字符串
本地化
容器
迭代器
范围
算法
数值
输入/输出
正则表达式
文件系统
线程支持
C 兼容
此头文件是格式化库的一部分。
类
formatter(C++20)
定义给定类型的格式化规则的类模板 (类模板)
basic_format_parse_contextformat_parse_contextwformat_parse_context(C++20)(C++20)(C++20)
格式化字符串分析器状态 (类模板)
basic_format_contextformat_contextwformat_context(C++20)(C++20)(C++20)
格式化状态,包括所有格式化参数和输出迭代器 (类模板)
basic_format_arg(C++20)
提供对用户定义格式化器的格式化参数的访问的类模板 (类模板)
basic_format_argsformat_argswformat_argsformat_args_t(C++20)(C++20)(C++20)(C++20)
提供对所有格式化参数的访问的类 (类模板)
format_error(C++20)
格式化错误时抛出的异常类型 (类)
函数
format(C++20)
在新 string 中存储参数的格式化表示 (函数模板)
format_to(C++20)
通过输出迭代器写其参数的格式化表示 (函数模板)
format_to_n(C++20)
通过输出迭代器写其参数的格式化表示,不超出指定的大小 (函数模板)
formatted_size(C++20)
确定存储其参数的格式化表示所需的字符数 (函数模板)
vformat(C++20)
std::format 的使用类型擦除的参数表示的非模板变体 (函数)
vformat_to(C++20)
std::format_to 的使用类型擦除的参数表示的非模板变体 (函数模板)
visit_format_arg(C++20)
用户定义格式化器的参数观览接口 (函数模板)
make_format_argsmake_wformat_args(C++20)(C++20)
创建引用所有格式化参数的类型擦除对象,可转换到 format_args (函数模板)
概要
namespace std {
// 格式化函数
template
string format(string_view fmt, const Args&... args);
template
wstring format(wstring_view fmt, const Args&... args);
template
string format(const locale& loc, string_view fmt, const Args&... args);
template
wstring format(const locale& loc, wstring_view fmt, const Args&... args);
string vformat(string_view fmt, format_args args);
wstring vformat(wstring_view fmt, wformat_args args);
string vformat(const locale& loc, string_view fmt, format_args args);
wstring vformat(const locale& loc, wstring_view fmt, wformat_args args);
template
Out format_to(Out out, string_view fmt, const Args&... args);
template
Out format_to(Out out, wstring_view fmt, const Args&... args);
template
Out format_to(Out out, const locale& loc, string_view fmt, const Args&... args);
template
Out format_to(Out out, const locale& loc, wstring_view fmt, const Args&... args);
template
Out vformat_to(Out out, string_view fmt,
format_args_t
template
Out vformat_to(Out out, wstring_view fmt,
format_args_t
template
Out vformat_to(Out out, const locale& loc, string_view fmt,
format_args_t
template
Out vformat_to(Out out, const locale& loc, wstring_view fmt,
format_args_t
template
Out out;
iter_difference_t
};
template
format_to_n_result
string_view fmt, const Args&... args);
template
format_to_n_result
wstring_view fmt, const Args&... args);
template
format_to_n_result
const locale& loc, string_view fmt,
const Args&... args);
template
format_to_n_result
const locale& loc, wstring_view fmt,
const Args&... args);
template
size_t formatted_size(string_view fmt, const Args&... args);
template
size_t formatted_size(wstring_view fmt, const Args&... args);
template
size_t formatted_size(const locale& loc, string_view fmt, const Args&... args);
template
size_t formatted_size(const locale& loc, wstring_view fmt, const Args&... args);
// 格式化器
template
// 类模板 basic_format_parse_context
template
using format_parse_context = basic_format_parse_context
using wformat_parse_context = basic_format_parse_context
template
using format_context = basic_format_context
using wformat_context = basic_format_context
// 实参
// 类模板 basic_format_arg
template
template
/* 见描述 */ visit_format_arg(Visitor&& vis, basic_format_arg
// class template format-arg-store
template
template
/*format-arg-store*/
make_format_args(const Args&... args);
template
/*format-arg-store*/
make_wformat_args(const Args&... args);
// 类模板 basic_format_args
template
using format_args = basic_format_args
using wformat_args = basic_format_args
template
using format_args_t = basic_format_args
// 类 format_error
class format_error;
}
类模板 std::basic_format_parse_context
namespace std {
template
class basic_format_parse_context {
public:
using char_type = charT;
using const_iterator = typename basic_string_view
using iterator = const_iterator;
private:
iterator begin_; // 仅为阐释
iterator end_; // 仅为阐释
enum indexing { unknown, manual, automatic }; // 仅为阐释
indexing indexing_; // 仅为阐释
size_t next_arg_id_; // 仅为阐释
size_t num_args_; // 仅为阐释
public:
constexpr explicit basic_format_parse_context(basic_string_view
size_t num_args = 0) noexcept;
basic_format_parse_context(const basic_format_parse_context&) = delete;
basic_format_parse_context& operator=(const basic_format_parse_context&) = delete;
constexpr const_iterator begin() const noexcept;
constexpr const_iterator end() const noexcept;
constexpr void advance_to(const_iterator it);
constexpr size_t next_arg_id();
constexpr void check_arg_id(size_t id);
};
}
类模板 std::basic_format_context
namespace std {
template
class basic_format_context {
basic_format_args
Out out_; // 仅为阐释
public:
using iterator = Out;
using char_type = charT;
template
basic_format_arg
std::locale locale();
iterator out();
void advance_to(iterator it);
};
}
类模板 std::basic_format_arg
namespace std {
template
class basic_format_arg {
public:
class handle;
private:
using char_type = typename Context::char_type; // 仅为阐释
variant int, unsigned int, long long int, unsigned long long int, float, double, long double, const char_type*, basic_string_view const void*, handle> value; // 仅为阐释 template explicit basic_format_arg(float n) noexcept; // 仅为阐释 explicit basic_format_arg(double n) noexcept; // 仅为阐释 explicit basic_format_arg(long double n) noexcept; // 仅为阐释 explicit basic_format_arg(const char_type* s); // 仅为阐释 template explicit basic_format_arg( basic_string_view template explicit basic_format_arg( const basic_string explicit basic_format_arg(nullptr_t) noexcept; // 仅为阐释 template explicit basic_format_arg(const T* p) noexcept; // 仅为阐释 public: basic_format_arg() noexcept; explicit operator bool() const noexcept; }; } 类 std::basic_format_arg::handle namespace std { template class basic_format_arg const void* ptr_; // 仅为阐释 void (*format_)(basic_format_parse_context Context&, const void*); // 仅为阐释 template friend class basic_format_arg public: void format(basic_format_parse_context }; } 类模板 format-arg-store namespace std { template struct /*format-arg-store*/ { // 仅为阐释 array }; } 类模板 std::basic_format_args namespace std { template class basic_format_args { size_t size_; // 仅为阐释 const basic_format_arg public: basic_format_args() noexcept; template basic_format_args(const /*format-arg-store*/ basic_format_arg }; } 类 std::format_error namespace std { class format_error : public runtime_error { public: explicit format_error(const string& what_arg); explicit format_error(const char* what_arg); }; }