Namespaces
Variants

std:: formattable

From cppreference.net
定义于头文件 <format>
template < class T, class CharT >

concept formattable = /* formattable_with */ <
std:: remove_reference_t < T > ,
std:: basic_format_context < /* fmt_iter_for */ < CharT > , CharT >

> ;
(1) (C++23 起)
辅助模板
template < class CharT >
using /* fmt_iter_for */ = /* 未指定 */ ;
(2) ( 仅用于说明* )
template < class T, class Context,

class Formatter =
typename Context :: template
formatter_type < std:: remove_const_t < T >> >
concept /* formattable_with */ =
std:: semiregular < Formatter > &&
requires ( Formatter & f, const Formatter & cf, T && t, Context fc,
std:: basic_format_parse_context <
typename Context :: char_type
> pc ) {
{ f. parse ( pc ) } - > std:: same_as < typename decltype ( pc ) :: iterator > ;
{ cf. format ( t, fc ) } - > std:: same_as < typename Context :: iterator > ;

} ;
(3) ( 仅用于说明* )

概念 formattable 规定 std:: formatter < std:: remove_cvref_t < T > , CharT > 满足 BasicFormatter Formatter 的要求(若 std:: remove_reference_t < T > 具有 const 限定)。

仅用于阐述的别名模板 /* fmt_iter_for */ 生成一个满足 std:: output_iterator < const CharT & > 要求的未指定类型。

缺陷报告

下列行为变更缺陷报告被追溯应用于先前发布的C++标准。

缺陷报告 应用于 发布时的行为 正确行为
LWG 3925 C++23 未提供 std::basic_format_context 的第二个模板参数 已提供

另请参阅

(C++20)
为给定类型定义格式化规则
(类模板)
为给定格式化参数类型和字符类型抽象化格式化操作
(命名要求)
(C++20)
定义由 格式化库 使用的函数
(命名要求)