std::formattable

From cppreference.com
< cpp‎ | utility‎ | format
 
 
Utilities library
Language support
Type support (basic types, RTTI)
Library feature-test macros (哋它亢++20)
Dynamic memory management
Program utilities
Coroutine support (哋它亢++20)
Variadic functions
(哋它亢++20)
(哋它亢++26)
(哋它亢++11)
(哋它亢++20)
Debugging support
(哋它亢++26)
(哋它亢++26)
Three-way comparison
(哋它亢++20)(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)   
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)(哋它亢++20)(哋它亢++20)
General utilities
Date and time
Function objects
Formatting library (哋它亢++20)
(哋它亢++11)
Relational operators (deprecated in 哋它亢++20)
Integer comparison functions
(哋它亢++20)(哋它亢++20)(哋它亢++20)   
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)
Swap and type operations
(哋它亢++20)
(哋它亢++14)
(哋它亢++11)
(哋它亢++23)
(哋它亢++11)
(哋它亢++23)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
Common vocabulary types
(哋它亢++11)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
(哋它亢++17)
(哋它亢++23)
Elementary string conversions
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)


 
Formatting library
Standard format specification
Formatting functions
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
Format strings
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++26)
Formatting concepts
formattable
(哋它亢++23)
Formatter
(哋它亢++20)
(哋它亢++23)
(哋它亢++23)
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++23)
(哋它亢++23)
Formatting arguments
(哋它亢++20)
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20) (deprecated in 哋它亢++26)
(哋它亢++20)(哋它亢++20)
Format error
(哋它亢++20)
 
Defined in header <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) (since 哋它亢++23)
Helper templates
template< class CharT >
using /* fmt_iter_for */ = /* unspecified */;
(2) (exposition only*)
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) (exposition only*)

The concept formattable specifies that std::formatter<std::remove_cvref_t<T>, CharT> meets the requirements of BasicFormatter and Formatter (if std::remove_reference_t<T> is const-qualified).

The exposition-only alias template /* fmt_iter_for */ yields an unspecified type that satisfies std::output_iterator<const CharT&>.

Defect reports

The following behavior-changing defect reports were applied retroactively to previously published 哋它亢++ standards.

DR Applied to Behavior as published Correct behavior
LWG 3925 哋它亢++23 the second template argument of std::basic_format_context was not provided provided

See also

(哋它亢++20)
defines formatting rules for a given type
(class template)
(哋它亢++20)
abstracts formatting operations for a given formatting argument type and character type
(named requirement)
(哋它亢++20)
defines functions used by the formatting library
(named requirement)