std::range-default-formatter<std::range_format::map>
来自 cppreference.cn
< cpp | utility | format | ranges formatter
定义于头文件 <format> |
||
template< ranges::input_range R, class CharT > struct /*range-default-formatter*/<range_format::map, R, CharT>; |
(C++23 起) (仅作说明*) |
|
当 std::format_kind<R> 为 std::range_format::map 时,类模板 /*range-default-formatter*/ 被特化用于将范围类型格式化为键值对的映射。
目录 |
[编辑] 成员类型
成员 | 定义 |
maybe-const-map (私有) |
fmt-maybe-const <R, CharT>(仅供说明的成员类型*) |
element-type (私有) |
std::remove_cvref_t<ranges::range_reference_t<maybe-const-map >>(仅供说明的成员类型*) |
[编辑] 数据成员
成员 | 定义 |
underlying_ (私有) |
类型为 std::range_formatter<element-type , CharT> 的底层格式化器(仅用于阐释的成员对象*) |
[编辑] 成员函数
(构造函数) |
构造一个 range-default-formatter (公开成员函数) |
parse |
根据 range-format-spec 指定的格式解析格式说明符 (公开成员函数) |
format |
根据 range-format-spec 指定的格式写入范围格式化输出 (公开成员函数) |
std::range-default-formatter<std::range_format::map>::range-default-formatter
constexpr /*range-default-formatter*/(); |
||
等价于
underlying_.set_brackets(STATICALLY_WIDEN<CharT>("{"), STATICALLY_WIDEN<CharT>("}"));
underlying_.underlying().set_brackets({}, {});
underlying_.underlying().set_separator(STATICALLY_WIDEN<charT>(": "));
其中 STATICALLY_WIDEN<CharT>("...") 是 "..." 如果 CharT
是 char,并且是 L"..." 如果 CharT
是 wchar_t。
程序格式不正确,除非
-
element-type
是 std::pair 的特化,或 -
element-type
是 std::tuple 的特化,并且std::tuple_size_v<element-type>
是 2。
std::range-default-formatter<std::range_format::map>::parse
template< class ParseContext > constexpr auto parse( ParseContext& ctx ) -> ParseContext::iterator; |
||
等价于: return
underlying_
.format(ctx);。
返回指向 *range-format-spec* 结尾的迭代器。
std::range-default-formatter<std::range_format::map>::format
template< class FormatContext > auto format( maybe-const-map& r, FormatContext& ctx ) const -> FormatContext::iterator; |
||
等价于: return
underlying_
.format(r, ctx);。
返回一个迭代器,指向输出范围的末尾之后。
[编辑] 另请参阅
(C++20) |
定义给定类型的格式化规则 (类模板) |
(C++23) |
有助于实现范围类型的 std::formatter 特化的类模板 (类模板) |