命名空间
变体
操作

std::formatter<std::queue>

来自 cppreference.cn
< cpp‎ | 容器‎ | queue
定义于头文件 <queue>
template< class CharT, class T, std::formattable<CharT> Container, class... U >
struct formatter<std::queue<T, Container, U...>, CharT>;
(C++23 起)

std::formatter 对容器适配器类型 std::queue 的模板特化,允许用户使用格式化函数将底层容器转换为其元素集合的文本表示。

std::formattable<Container, CharT>true 时,该特化被启用。

目录

[编辑] 成员类型

名称 定义
maybe-const-container fmt-maybe-const <Container, CharT>
(仅供说明的成员类型*)
maybe-const-adaptor maybe-const <
    std::is_const_v<maybe-const-container>,
    std::queue<T, Container, U...>>

(仅供说明的成员类型*)

[编辑] 数据成员

名称 定义
underlying_ 类型为 std::formatter<ranges::ref_view<maybe-const-container>, CharT> 的底层格式化器
(仅用于阐释的成员对象*)

[编辑] 成员函数

parse
range-format-spec 指定解析格式说明符
(公开成员函数)
format
range-format-spec 指定写入范围格式化输出
(公开成员函数)

std::formatter<std::queue>::parse

template< class ParseContext >
constexpr auto parse( ParseContext& ctx ) -> ParseContext::iterator;

等价于 return underlying_ .parse(ctx);

返回值

指向底层容器的 range-format-spec 尾后位置的迭代器。

std::formatter<std::queue>::format

template< class FormatContext >

auto format( /*maybe-const-adaptor*/& r, FormatContext& ctx ) const

    -> FormatContext::iterator;

等价于 return underlying_ .format(r.c, ctx);

返回值

指向输出范围的尾后位置的迭代器。

[编辑] 示例

[编辑] 参阅

(C++20)
定义给定类型的格式化规则
(类模板) [编辑]
有助于实现范围类型的 std::formatter 特化的类模板
(类模板) [编辑]