std::formattable

From cppreference.com
< cpp‎ | utility‎ | format
 
 
Utilities library
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)   
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)
Elementary string conversions
(C++17)
(C++17)
 
Formatting library
Formatting functions
(C++20)
(C++20)
(C++20)
(C++20)
Formatting concepts
formattable
(C++23)
Formatter
(C++20)
Formatting arguments
(C++20) (deprecated in C++26)
Format error
 
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 C++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&>.

See also

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