命名空间
变体
操作

std::formatter<std::stack>

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

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

如果 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::stack<T, Container, U...>>

(仅为说明目的的成员类型*)

[编辑] 数据成员

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

[编辑] 成员函数

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

std::formatter<std::stack>::parse

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

等价于 return underlying_ .parse(ctx);.

返回值

一个迭代器,指向底层容器的 range-format-spec 的末尾之后。

std::formatter<std::stack>::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 特化
(类模板) [编辑]