std::formattable(3)
π std::formattable(3) π
okay bestie, welcome to the std::formattable(3) page from the C++ Standard Libary manual β yes, thatβs the manual name, and weβre not fixing the spelling, weβre just living with it π
. This page is short but every detail matters, so letβs get into it.
π NAME π
std::formattable β literally std::formattable. Thatβs the name, periodt.
β¨ Synopsis β¨
Defined in header <format>.
template< class T, class CharT >
concept formattable = /* formattable_with */<
std::remove_reference_t<T>, (1)
(since C++23)
std::basic_format_context</* fmt_iter_for */<CharT>, CharT>
>;
Helper templates
template< class CharT > (2)
(exposition only*)
using /* fmt_iter_for */ = /* unspecified */;
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, (3)
(exposition only*)
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>;
};
okay so hereβs the tea β: 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).
and the exposition-only alias template /* fmt_iter_for */ yields an unspecified type that satisfies std::output_iterator<const CharT&>.
exposition-only means exposition-only, bestie β thatβs literally what the page says, so donβt go treating those bits like public API lore π«Ά
π Defect reports π
the committee pulled up with receipts: the following behavior-changing defect reports were applied retroactively to previously published C++ standards.
LWG 3925β applied toC++23. Behavior as published: βthe second template argument ofstd::basic_format_contextwas not providedβ. Correct behavior: βprovidedβ.
π¦ See also π¦
formatter(C++20) β defines formatting rules for a given type (class template).BasicFormatter(C++20) β abstracts formatting operations for a given formatting argument type and character type (named requirement).Formatter(C++20) β defines functions used by the formatting library (named requirement).
source/version + date check, bestie: http://cppreference.com, 2024.06.10 β thatβs the footer vibes, and we are so done here. mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms