mirror of
https://github.com/fmtlib/fmt.git
synced 2025-01-28 18:32:46 +00:00
Clarify requirement on compiled formatter
This commit is contained in:
parent
fb97cb2318
commit
95e1ea5737
18
doc/api.rst
18
doc/api.rst
@ -549,10 +549,20 @@ Format String Compilation
|
|||||||
``FMT_COMPILE`` macro or the ``_cf`` user-defined literal. Format strings
|
``FMT_COMPILE`` macro or the ``_cf`` user-defined literal. Format strings
|
||||||
marked with ``FMT_COMPILE`` or ``_cf`` are parsed, checked and converted into
|
marked with ``FMT_COMPILE`` or ``_cf`` are parsed, checked and converted into
|
||||||
efficient formatting code at compile-time. This supports arguments of built-in
|
efficient formatting code at compile-time. This supports arguments of built-in
|
||||||
and string types as well as user-defined types with ``constexpr`` ``parse``
|
and string types as well as user-defined types with ``format`` functions taking
|
||||||
functions in their ``formatter`` specializations. Format string compilation can
|
the format context type as a template parameter in their ``formatter``
|
||||||
generate more binary code compared to the default API and is only recommended in
|
specializations. For example::
|
||||||
places where formatting is a performance bottleneck.
|
|
||||||
|
template <> struct fmt::formatter<point> {
|
||||||
|
constexpr auto parse(format_parse_context& ctx);
|
||||||
|
|
||||||
|
template <typename FormatContext>
|
||||||
|
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
|
.. doxygendefine:: FMT_COMPILE
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user