Clarify docs for compile-time checks

This commit is contained in:
Victor Zverovich 2022-08-05 07:00:34 -07:00
parent 90c48b8525
commit df56fdf883

View File

@ -7,7 +7,7 @@ API Reference
The {fmt} library API consists of the following parts: The {fmt} library API consists of the following parts:
* :ref:`fmt/core.h <core-api>`: the core API providing main formatting functions * :ref:`fmt/core.h <core-api>`: the core API providing main formatting functions
for ``char``/UTF-8 with compile-time checks and minimal dependencies for ``char``/UTF-8 with C++20 compile-time checks and minimal dependencies
* :ref:`fmt/format.h <format-api>`: the full format API providing additional * :ref:`fmt/format.h <format-api>`: the full format API providing additional
formatting functions and locale support formatting functions and locale support
* :ref:`fmt/ranges.h <ranges-api>`: formatting of ranges and tuples * :ref:`fmt/ranges.h <ranges-api>`: formatting of ranges and tuples
@ -28,10 +28,10 @@ macros have prefix ``FMT_``.
Core API Core API
======== ========
``fmt/core.h`` defines the core API which provides main formatting functions for ``fmt/core.h`` defines the core API which provides main formatting functions
``char``/UTF-8 with compile-time checks. It has minimal include dependencies for for ``char``/UTF-8 with C++20 compile-time checks. It has minimal include
better compile times. This header is only beneficial when using {fmt} as a dependencies for better compile times. This header is only beneficial when
library and not in the header-only mode. using {fmt} as a library and not in the header-only mode.
The following functions use :ref:`format string syntax <syntax>` The following functions use :ref:`format string syntax <syntax>`
similar to that of Python's `str.format similar to that of Python's `str.format
@ -70,17 +70,16 @@ checked at compile time in C++20. To pass a runtime format string wrap it in
Compile-Time Format String Checks Compile-Time Format String Checks
--------------------------------- ---------------------------------
Compile-time checks are enabled when using ``FMT_STRING``. They support built-in Compile-time checks are enabled by default on compilers that support C++20
and string types as well as user-defined types with ``constexpr`` ``parse`` ``consteval``. On older compilers you can use the ``FMT_STRING`` macro defined
functions in their ``formatter`` specializations. in ``fmt/format.h`` instead. It requires C++14 and is a no-op in C++11.
Requires C++14 and is a no-op in C++11.
.. doxygendefine:: FMT_STRING .. doxygendefine:: FMT_STRING
To force the use of compile-time checks, define the preprocessor variable To force the use of legacy compile-time checks, define the preprocessor variable
``FMT_ENFORCE_COMPILE_STRING``. When set, functions accepting ``FMT_STRING`` ``FMT_ENFORCE_COMPILE_STRING``. When set, functions accepting ``FMT_STRING``
will fail to compile with regular strings. Runtime-checked will fail to compile with regular strings. Runtime-checked formatting is still
formatting is still possible using ``fmt::vformat``, ``fmt::vprint``, etc. possible using ``fmt::vformat``, ``fmt::vprint``, etc.
.. doxygenclass:: fmt::basic_format_string .. doxygenclass:: fmt::basic_format_string
:members: :members: