std::formatter<std::stack>

来自cppreference.com
< cpp‎ | container‎ | stack
在标头 <stack> 定义
template<class CharT, class T, std::formattable<CharT> Container, class... U>
struct formatter<std::stack<T, Container, U...>, CharT>;
(C++23 起)

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

如果 std::formattable<Container, CharT>true 则启用此特化。

目录

[编辑]成员类型

名称 定义
maybe-const-containerfmt-maybe-const <Container, CharT>
(仅用于阐述的成员类型*)
maybe-const-adaptormaybe-const <
    std::is_const_v<maybe-const-container>,
    std::stack<T, Container, U...>>

(仅用于阐述的成员类型*)

[编辑]数据成员

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

[编辑]成员函数

parse
根据 范围格式说明 解析格式说明符
(公开成员函数)
format
根据 范围格式说明 写入范围的格式化输出
(公开成员函数)

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

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

等价于 return underlying_ .parse(ctx);

返回值

底层容器的 范围格式说明 的尾后迭代器。

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 对范围类型的特化的类模板
(类模板)[编辑]
close