api.rst 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. .. _string-formatting-api:
  2. *************
  3. API Reference
  4. *************
  5. The {fmt} library API consists of the following parts:
  6. * :ref:`fmt/core.h <core-api>`: the core API providing main formatting functions
  7. for ``char``/UTF-8 with C++20 compile-time checks and minimal dependencies
  8. * :ref:`fmt/format.h <format-api>`: the full format API providing additional
  9. formatting functions and locale support
  10. * :ref:`fmt/ranges.h <ranges-api>`: formatting of ranges and tuples
  11. * :ref:`fmt/chrono.h <chrono-api>`: date and time formatting
  12. * :ref:`fmt/std.h <std-api>`: formatters for standard library types
  13. * :ref:`fmt/compile.h <compile-api>`: format string compilation
  14. * :ref:`fmt/color.h <color-api>`: terminal color and text style
  15. * :ref:`fmt/os.h <os-api>`: system APIs
  16. * :ref:`fmt/ostream.h <ostream-api>`: ``std::ostream`` support
  17. * :ref:`fmt/args.h <args-api>`: dynamic argument lists
  18. * :ref:`fmt/printf.h <printf-api>`: ``printf`` formatting
  19. * :ref:`fmt/xchar.h <xchar-api>`: optional ``wchar_t`` support
  20. All functions and types provided by the library reside in namespace ``fmt`` and
  21. macros have prefix ``FMT_``.
  22. .. _core-api:
  23. Core API
  24. ========
  25. ``fmt/core.h`` defines the core API which provides main formatting functions
  26. for ``char``/UTF-8 with C++20 compile-time checks. It has minimal include
  27. dependencies for better compile times. This header is only beneficial when
  28. using {fmt} as a library (the default) and not in the header-only mode.
  29. It also provides ``formatter`` specializations for built-in and string types.
  30. The following functions use :ref:`format string syntax <syntax>`
  31. similar to that of Python's `str.format
  32. <https://docs.python.org/3/library/stdtypes.html#str.format>`_.
  33. They take *fmt* and *args* as arguments.
  34. *fmt* is a format string that contains literal text and replacement fields
  35. surrounded by braces ``{}``. The fields are replaced with formatted arguments
  36. in the resulting string. `~fmt::format_string` is a format string which can be
  37. implicitly constructed from a string literal or a ``constexpr`` string and is
  38. checked at compile time in C++20. To pass a runtime format string wrap it in
  39. `fmt::runtime`.
  40. *args* is an argument list representing objects to be formatted.
  41. .. _format:
  42. .. doxygenfunction:: format(format_string<T...> fmt, T&&... args) -> std::string
  43. .. doxygenfunction:: vformat(string_view fmt, format_args args) -> std::string
  44. .. doxygenfunction:: format_to(OutputIt out, format_string<T...> fmt, T&&... args) -> OutputIt
  45. .. doxygenfunction:: format_to_n(OutputIt out, size_t n, format_string<T...> fmt, T&&... args) -> format_to_n_result<OutputIt>
  46. .. doxygenfunction:: formatted_size(format_string<T...> fmt, T&&... args) -> size_t
  47. .. doxygenstruct:: fmt::format_to_n_result
  48. :members:
  49. .. _print:
  50. .. doxygenfunction:: fmt::print(format_string<T...> fmt, T&&... args)
  51. .. doxygenfunction:: fmt::vprint(string_view fmt, format_args args)
  52. .. doxygenfunction:: print(std::FILE *f, format_string<T...> fmt, T&&... args)
  53. .. doxygenfunction:: vprint(std::FILE *f, string_view fmt, format_args args)
  54. Compile-Time Format String Checks
  55. ---------------------------------
  56. Compile-time format string checks are enabled by default on compilers
  57. that support C++20 ``consteval``. On older compilers you can use the
  58. :ref:`FMT_STRING <legacy-checks>`: macro defined in ``fmt/format.h`` instead.
  59. Unused arguments are allowed as in Python's `str.format` and ordinary functions.
  60. .. doxygenclass:: fmt::basic_format_string
  61. :members:
  62. .. doxygentypedef:: fmt::format_string
  63. .. doxygenfunction:: fmt::runtime(string_view) -> runtime_format_string<>
  64. .. _udt:
  65. Formatting User-Defined Types
  66. -----------------------------
  67. The {fmt} library provides formatters for many standard C++ types.
  68. See :ref:`fmt/ranges.h <ranges-api>` for ranges and tuples including standard
  69. containers such as ``std::vector``, :ref:`fmt/chrono.h <chrono-api>` for date
  70. and time formatting and :ref:`fmt/std.h <std-api>` for other standard library
  71. types.
  72. There are two ways to make a user-defined type formattable: providing a
  73. ``format_as`` function or specializing the ``formatter`` struct template.
  74. Use ``format_as`` if you want to make your type formattable as some other type
  75. with the same format specifiers. The ``format_as`` function should take an
  76. object of your type and return an object of a formattable type. It should be
  77. defined in the same namespace as your type.
  78. Example (https://godbolt.org/z/r7vvGE1v7)::
  79. #include <fmt/format.h>
  80. namespace kevin_namespacy {
  81. enum class film {
  82. house_of_cards, american_beauty, se7en = 7
  83. };
  84. auto format_as(film f) { return fmt::underlying(f); }
  85. }
  86. int main() {
  87. fmt::print("{}\n", kevin_namespacy::film::se7en); // prints "7"
  88. }
  89. Using the specialization API is more complex but gives you full control over
  90. parsing and formatting. To use this method specialize the ``formatter`` struct
  91. template for your type and implement ``parse`` and ``format`` methods.
  92. For example::
  93. #include <fmt/core.h>
  94. struct point {
  95. double x, y;
  96. };
  97. template <> struct fmt::formatter<point> {
  98. // Presentation format: 'f' - fixed, 'e' - exponential.
  99. char presentation = 'f';
  100. // Parses format specifications of the form ['f' | 'e'].
  101. constexpr auto parse(format_parse_context& ctx) -> format_parse_context::iterator {
  102. // [ctx.begin(), ctx.end()) is a character range that contains a part of
  103. // the format string starting from the format specifications to be parsed,
  104. // e.g. in
  105. //
  106. // fmt::format("{:f} - point of interest", point{1, 2});
  107. //
  108. // the range will contain "f} - point of interest". The formatter should
  109. // parse specifiers until '}' or the end of the range. In this example
  110. // the formatter should parse the 'f' specifier and return an iterator
  111. // pointing to '}'.
  112. // Please also note that this character range may be empty, in case of
  113. // the "{}" format string, so therefore you should check ctx.begin()
  114. // for equality with ctx.end().
  115. // Parse the presentation format and store it in the formatter:
  116. auto it = ctx.begin(), end = ctx.end();
  117. if (it != end && (*it == 'f' || *it == 'e')) presentation = *it++;
  118. // Check if reached the end of the range:
  119. if (it != end && *it != '}') throw_format_error("invalid format");
  120. // Return an iterator past the end of the parsed range:
  121. return it;
  122. }
  123. // Formats the point p using the parsed format specification (presentation)
  124. // stored in this formatter.
  125. auto format(const point& p, format_context& ctx) const -> format_context::iterator {
  126. // ctx.out() is an output iterator to write to.
  127. return presentation == 'f'
  128. ? fmt::format_to(ctx.out(), "({:.1f}, {:.1f})", p.x, p.y)
  129. : fmt::format_to(ctx.out(), "({:.1e}, {:.1e})", p.x, p.y);
  130. }
  131. };
  132. Then you can pass objects of type ``point`` to any formatting function::
  133. point p = {1, 2};
  134. std::string s = fmt::format("{:f}", p);
  135. // s == "(1.0, 2.0)"
  136. You can also reuse existing formatters via inheritance or composition, for
  137. example::
  138. // color.h:
  139. #include <fmt/core.h>
  140. enum class color {red, green, blue};
  141. template <> struct fmt::formatter<color>: formatter<string_view> {
  142. // parse is inherited from formatter<string_view>.
  143. auto format(color c, format_context& ctx) const;
  144. };
  145. // color.cc:
  146. #include "color.h"
  147. #include <fmt/format.h>
  148. auto fmt::formatter<color>::format(color c, format_context& ctx) const {
  149. string_view name = "unknown";
  150. switch (c) {
  151. case color::red: name = "red"; break;
  152. case color::green: name = "green"; break;
  153. case color::blue: name = "blue"; break;
  154. }
  155. return formatter<string_view>::format(name, ctx);
  156. }
  157. Note that ``formatter<string_view>::format`` is defined in ``fmt/format.h`` so
  158. it has to be included in the source file.
  159. Since ``parse`` is inherited from ``formatter<string_view>`` it will recognize
  160. all string format specifications, for example
  161. .. code-block:: c++
  162. fmt::format("{:>10}", color::blue)
  163. will return ``" blue"``.
  164. You can also write a formatter for a hierarchy of classes::
  165. // demo.h:
  166. #include <type_traits>
  167. #include <fmt/core.h>
  168. struct A {
  169. virtual ~A() {}
  170. virtual std::string name() const { return "A"; }
  171. };
  172. struct B : A {
  173. virtual std::string name() const { return "B"; }
  174. };
  175. template <typename T>
  176. struct fmt::formatter<T, std::enable_if_t<std::is_base_of<A, T>::value, char>> :
  177. fmt::formatter<std::string> {
  178. auto format(const A& a, format_context& ctx) const {
  179. return fmt::formatter<std::string>::format(a.name(), ctx);
  180. }
  181. };
  182. // demo.cc:
  183. #include "demo.h"
  184. #include <fmt/format.h>
  185. int main() {
  186. B b;
  187. A& a = b;
  188. fmt::print("{}", a); // prints "B"
  189. }
  190. Providing both a ``formatter`` specialization and a ``format_as`` overload is
  191. disallowed.
  192. Named Arguments
  193. ---------------
  194. .. doxygenfunction:: fmt::arg(const S&, const T&)
  195. Named arguments are not supported in compile-time checks at the moment.
  196. Argument Lists
  197. --------------
  198. You can create your own formatting function with compile-time checks and small
  199. binary footprint, for example (https://godbolt.org/z/vajfWEG4b):
  200. .. code:: c++
  201. #include <fmt/core.h>
  202. void vlog(const char* file, int line, fmt::string_view format,
  203. fmt::format_args args) {
  204. fmt::print("{}: {}: ", file, line);
  205. fmt::vprint(format, args);
  206. }
  207. template <typename... T>
  208. void log(const char* file, int line, fmt::format_string<T...> format, T&&... args) {
  209. vlog(file, line, format, fmt::make_format_args(args...));
  210. }
  211. #define MY_LOG(format, ...) log(__FILE__, __LINE__, format, __VA_ARGS__)
  212. MY_LOG("invalid squishiness: {}", 42);
  213. Note that ``vlog`` is not parameterized on argument types which improves compile
  214. times and reduces binary code size compared to a fully parameterized version.
  215. .. doxygenfunction:: fmt::make_format_args(const Args&...)
  216. .. doxygenclass:: fmt::format_arg_store
  217. :members:
  218. .. doxygenclass:: fmt::basic_format_args
  219. :members:
  220. .. doxygentypedef:: fmt::format_args
  221. .. doxygenclass:: fmt::basic_format_arg
  222. :members:
  223. .. doxygenclass:: fmt::basic_format_parse_context
  224. :members:
  225. .. doxygenclass:: fmt::basic_format_context
  226. :members:
  227. .. doxygentypedef:: fmt::format_context
  228. .. _args-api:
  229. Dynamic Argument Lists
  230. ----------------------
  231. The header ``fmt/args.h`` provides ``dynamic_format_arg_store``, a builder-like
  232. API that can be used to construct format argument lists dynamically.
  233. .. doxygenclass:: fmt::dynamic_format_arg_store
  234. :members:
  235. Compatibility
  236. -------------
  237. .. doxygenclass:: fmt::basic_string_view
  238. :members:
  239. .. doxygentypedef:: fmt::string_view
  240. .. _format-api:
  241. Format API
  242. ==========
  243. ``fmt/format.h`` defines the full format API providing additional formatting
  244. functions and locale support.
  245. Literal-Based API
  246. -----------------
  247. The following user-defined literals are defined in ``fmt/format.h``.
  248. .. doxygenfunction:: operator""_a()
  249. Utilities
  250. ---------
  251. .. doxygenfunction:: fmt::ptr(T p) -> const void*
  252. .. doxygenfunction:: fmt::ptr(const std::unique_ptr<T, Deleter> &p) -> const void*
  253. .. doxygenfunction:: fmt::ptr(const std::shared_ptr<T> &p) -> const void*
  254. .. doxygenfunction:: fmt::underlying(Enum e) -> typename std::underlying_type<Enum>::type
  255. .. doxygenfunction:: fmt::to_string(const T &value) -> std::string
  256. .. doxygenfunction:: fmt::join(Range &&range, string_view sep) -> join_view<detail::iterator_t<Range>, detail::sentinel_t<Range>>
  257. .. doxygenfunction:: fmt::join(It begin, Sentinel end, string_view sep) -> join_view<It, Sentinel>
  258. .. doxygenfunction:: fmt::group_digits(T value) -> group_digits_view<T>
  259. .. doxygenclass:: fmt::detail::buffer
  260. :members:
  261. .. doxygenclass:: fmt::basic_memory_buffer
  262. :protected-members:
  263. :members:
  264. System Errors
  265. -------------
  266. {fmt} does not use ``errno`` to communicate errors to the user, but it may call
  267. system functions which set ``errno``. Users should not make any assumptions
  268. about the value of ``errno`` being preserved by library functions.
  269. .. doxygenfunction:: fmt::system_error
  270. .. doxygenfunction:: fmt::format_system_error
  271. Custom Allocators
  272. -----------------
  273. The {fmt} library supports custom dynamic memory allocators.
  274. A custom allocator class can be specified as a template argument to
  275. :class:`fmt::basic_memory_buffer`::
  276. using custom_memory_buffer =
  277. fmt::basic_memory_buffer<char, fmt::inline_buffer_size, custom_allocator>;
  278. It is also possible to write a formatting function that uses a custom
  279. allocator::
  280. using custom_string =
  281. std::basic_string<char, std::char_traits<char>, custom_allocator>;
  282. custom_string vformat(custom_allocator alloc, fmt::string_view format_str,
  283. fmt::format_args args) {
  284. auto buf = custom_memory_buffer(alloc);
  285. fmt::vformat_to(std::back_inserter(buf), format_str, args);
  286. return custom_string(buf.data(), buf.size(), alloc);
  287. }
  288. template <typename ...Args>
  289. inline custom_string format(custom_allocator alloc,
  290. fmt::string_view format_str,
  291. const Args& ... args) {
  292. return vformat(alloc, format_str, fmt::make_format_args(args...));
  293. }
  294. The allocator will be used for the output container only. Formatting functions
  295. normally don't do any allocations for built-in and string types except for
  296. non-default floating-point formatting that occasionally falls back on
  297. ``sprintf``.
  298. Locale
  299. ------
  300. All formatting is locale-independent by default. Use the ``'L'`` format
  301. specifier to insert the appropriate number separator characters from the
  302. locale::
  303. #include <fmt/core.h>
  304. #include <locale>
  305. std::locale::global(std::locale("en_US.UTF-8"));
  306. auto s = fmt::format("{:L}", 1000000); // s == "1,000,000"
  307. ``fmt/format.h`` provides the following overloads of formatting functions that
  308. take ``std::locale`` as a parameter. The locale type is a template parameter to
  309. avoid the expensive ``<locale>`` include.
  310. .. doxygenfunction:: format(const Locale& loc, format_string<T...> fmt, T&&... args) -> std::string
  311. .. doxygenfunction:: format_to(OutputIt out, const Locale& loc, format_string<T...> fmt, T&&... args) -> OutputIt
  312. .. doxygenfunction:: formatted_size(const Locale& loc, format_string<T...> fmt, T&&... args) -> size_t
  313. .. _legacy-checks:
  314. Legacy Compile-Time Format String Checks
  315. ----------------------------------------
  316. ``FMT_STRING`` enables compile-time checks on older compilers. It requires C++14
  317. or later and is a no-op in C++11.
  318. .. doxygendefine:: FMT_STRING
  319. To force the use of legacy compile-time checks, define the preprocessor variable
  320. ``FMT_ENFORCE_COMPILE_STRING``. When set, functions accepting ``FMT_STRING``
  321. will fail to compile with regular strings.
  322. .. _ranges-api:
  323. Range and Tuple Formatting
  324. ==========================
  325. The library also supports convenient formatting of ranges and tuples::
  326. #include <fmt/ranges.h>
  327. std::tuple<char, int, float> t{'a', 1, 2.0f};
  328. // Prints "('a', 1, 2.0)"
  329. fmt::print("{}", t);
  330. NOTE: currently, the overload of ``fmt::join`` for iterables exists in the main
  331. ``format.h`` header, but expect this to change in the future.
  332. Using ``fmt::join``, you can separate tuple elements with a custom separator::
  333. #include <fmt/ranges.h>
  334. std::tuple<int, char> t = {1, 'a'};
  335. // Prints "1, a"
  336. fmt::print("{}", fmt::join(t, ", "));
  337. .. _chrono-api:
  338. Date and Time Formatting
  339. ========================
  340. ``fmt/chrono.h`` provides formatters for
  341. * `std::chrono::duration <https://en.cppreference.com/w/cpp/chrono/duration>`_
  342. * `std::chrono::time_point
  343. <https://en.cppreference.com/w/cpp/chrono/time_point>`_
  344. * `std::tm <https://en.cppreference.com/w/cpp/chrono/c/tm>`_
  345. The format syntax is described in :ref:`chrono-specs`.
  346. **Example**::
  347. #include <fmt/chrono.h>
  348. int main() {
  349. std::time_t t = std::time(nullptr);
  350. // Prints "The date is 2020-11-07." (with the current date):
  351. fmt::print("The date is {:%Y-%m-%d}.", fmt::localtime(t));
  352. using namespace std::literals::chrono_literals;
  353. // Prints "Default format: 42s 100ms":
  354. fmt::print("Default format: {} {}\n", 42s, 100ms);
  355. // Prints "strftime-like format: 03:15:30":
  356. fmt::print("strftime-like format: {:%H:%M:%S}\n", 3h + 15min + 30s);
  357. }
  358. .. doxygenfunction:: localtime(std::time_t time)
  359. .. doxygenfunction:: gmtime(std::time_t time)
  360. .. _std-api:
  361. Standard Library Types Formatting
  362. =================================
  363. ``fmt/std.h`` provides formatters for:
  364. * `std::filesystem::path <https://en.cppreference.com/w/cpp/filesystem/path>`_
  365. * `std::thread::id <https://en.cppreference.com/w/cpp/thread/thread/id>`_
  366. * `std::monostate <https://en.cppreference.com/w/cpp/utility/variant/monostate>`_
  367. * `std::variant <https://en.cppreference.com/w/cpp/utility/variant/variant>`_
  368. * `std::optional <https://en.cppreference.com/w/cpp/utility/optional>`_
  369. Formatting Variants
  370. -------------------
  371. A ``std::variant`` is only formattable if every variant alternative is formattable, and requires the
  372. ``__cpp_lib_variant`` `library feature <https://en.cppreference.com/w/cpp/feature_test>`_.
  373. **Example**::
  374. #include <fmt/std.h>
  375. std::variant<char, float> v0{'x'};
  376. // Prints "variant('x')"
  377. fmt::print("{}", v0);
  378. std::variant<std::monostate, char> v1;
  379. // Prints "variant(monostate)"
  380. .. _compile-api:
  381. Format String Compilation
  382. =========================
  383. ``fmt/compile.h`` provides format string compilation enabled via the
  384. ``FMT_COMPILE`` macro or the ``_cf`` user-defined literal. Format strings
  385. marked with ``FMT_COMPILE`` or ``_cf`` are parsed, checked and converted into
  386. efficient formatting code at compile-time. This supports arguments of built-in
  387. and string types as well as user-defined types with ``format`` functions taking
  388. the format context type as a template parameter in their ``formatter``
  389. specializations. For example::
  390. template <> struct fmt::formatter<point> {
  391. constexpr auto parse(format_parse_context& ctx);
  392. template <typename FormatContext>
  393. auto format(const point& p, FormatContext& ctx) const;
  394. };
  395. Format string compilation can generate more binary code compared to the default
  396. API and is only recommended in places where formatting is a performance
  397. bottleneck.
  398. .. doxygendefine:: FMT_COMPILE
  399. .. doxygenfunction:: operator""_cf()
  400. .. _color-api:
  401. Terminal Color and Text Style
  402. =============================
  403. ``fmt/color.h`` provides support for terminal color and text style output.
  404. .. doxygenfunction:: print(const text_style &ts, const S &format_str, const Args&... args)
  405. .. doxygenfunction:: fg(detail::color_type)
  406. .. doxygenfunction:: bg(detail::color_type)
  407. .. doxygenfunction:: styled(const T& value, text_style ts)
  408. .. _os-api:
  409. System APIs
  410. ===========
  411. .. doxygenclass:: fmt::ostream
  412. :members:
  413. .. doxygenfunction:: fmt::windows_error
  414. :members:
  415. .. _ostream-api:
  416. ``std::ostream`` Support
  417. ========================
  418. ``fmt/ostream.h`` provides ``std::ostream`` support including formatting of
  419. user-defined types that have an overloaded insertion operator (``operator<<``).
  420. In order to make a type formattable via ``std::ostream`` you should provide a
  421. ``formatter`` specialization inherited from ``ostream_formatter``::
  422. #include <fmt/ostream.h>
  423. struct date {
  424. int year, month, day;
  425. friend std::ostream& operator<<(std::ostream& os, const date& d) {
  426. return os << d.year << '-' << d.month << '-' << d.day;
  427. }
  428. };
  429. template <> struct fmt::formatter<date> : ostream_formatter {};
  430. std::string s = fmt::format("The date is {}", date{2012, 12, 9});
  431. // s == "The date is 2012-12-9"
  432. .. doxygenfunction:: streamed(const T &)
  433. .. doxygenfunction:: print(std::ostream &os, format_string<T...> fmt, T&&... args)
  434. .. _printf-api:
  435. ``printf`` Formatting
  436. =====================
  437. The header ``fmt/printf.h`` provides ``printf``-like formatting functionality.
  438. The following functions use `printf format string syntax
  439. <https://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html>`_ with
  440. the POSIX extension for positional arguments. Unlike their standard
  441. counterparts, the ``fmt`` functions are type-safe and throw an exception if an
  442. argument type doesn't match its format specification.
  443. .. doxygenfunction:: printf(string_view fmt, const T&... args) -> int
  444. .. doxygenfunction:: fprintf(std::FILE *f, const S &fmt, const T&... args) -> int
  445. .. doxygenfunction:: sprintf(const S&, const T&...)
  446. .. _xchar-api:
  447. ``wchar_t`` Support
  448. ===================
  449. The optional header ``fmt/xchar.h`` provides support for ``wchar_t`` and exotic
  450. character types.
  451. .. doxygenstruct:: fmt::is_char
  452. .. doxygentypedef:: fmt::wstring_view
  453. .. doxygentypedef:: fmt::wformat_context
  454. .. doxygenfunction:: fmt::to_wstring(const T &value)
  455. Compatibility with C++20 ``std::format``
  456. ========================================
  457. {fmt} implements nearly all of the `C++20 formatting library
  458. <https://en.cppreference.com/w/cpp/utility/format>`_ with the following
  459. differences:
  460. * Names are defined in the ``fmt`` namespace instead of ``std`` to avoid
  461. collisions with standard library implementations.
  462. * Width calculation doesn't use grapheme clusterization. The latter has been
  463. implemented in a separate branch but hasn't been integrated yet.
  464. * Most C++20 chrono types are not supported yet.