From 95e1ea57371fc044524574c170d53d97cdec2a13 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Thu, 20 Jul 2023 10:24:02 -0700 Subject: [PATCH] Clarify requirement on compiled formatter --- doc/api.rst | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/doc/api.rst b/doc/api.rst index 488f3587..ce4adb6a 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -549,10 +549,20 @@ Format String Compilation ``FMT_COMPILE`` macro or the ``_cf`` user-defined literal. Format strings marked with ``FMT_COMPILE`` or ``_cf`` are parsed, checked and converted into efficient formatting code at compile-time. This supports arguments of built-in -and string types as well as user-defined types with ``constexpr`` ``parse`` -functions in their ``formatter`` specializations. Format string compilation can -generate more binary code compared to the default API and is only recommended in -places where formatting is a performance bottleneck. +and string types as well as user-defined types with ``format`` functions taking +the format context type as a template parameter in their ``formatter`` +specializations. For example:: + + template <> struct fmt::formatter { + constexpr auto parse(format_parse_context& ctx); + + template + auto format(const point& p, FormatContext& ctx) const; + }; + +Format string compilation can generate more binary code compared to the default +API and is only recommended in places where formatting is a performance +bottleneck. .. doxygendefine:: FMT_COMPILE