命名空间
变体
操作

std::formattable

来自 cppreference.cn
< cpp‎ | utility‎ | format
 
 
 
 
定义于头文件 <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 */ = /* unspecified */;
(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> 满足 BasicFormatterFormatter 的要求(如果 std::remove_reference_t<T> 是 const 限定的)。

仅供演示的别名模板 /* fmt_iter_for */ 产生一个未指定的类型,该类型满足 std::output_iterator<const CharT&>

[编辑] 缺陷报告

以下行为更改缺陷报告已追溯应用于先前发布的 C++ 标准。

DR 应用于 已发布行为 正确行为
LWG 3925 C++23 std::basic_format_context 的第二个模板实参未提供 已提供

[编辑] 参见

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