From c48353cb753889c38a94809b5bc72cedc1dedd26 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 13 Feb 2022 07:40:43 -0800 Subject: [PATCH] Update docs --- doc/api.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/api.rst b/doc/api.rst index 46070ed6..cc17effe 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -493,7 +493,9 @@ System APIs ======================== ``fmt/ostream.h`` provides ``std::ostream`` support including formatting of -user-defined types that have an overloaded insertion operator (``operator<<``):: +user-defined types that have an overloaded insertion operator (``operator<<``). +In order to make a type formattable via ``std::ostream`` you should provide a +``formatter`` specialization inherited from ``ostream_formatter``: #include @@ -507,14 +509,11 @@ user-defined types that have an overloaded insertion operator (``operator<<``):: } }; - template <> struct fmt::formatter : ostream_formatter {}; + template <> struct fmt::formatter : ostream_formatter {}; std::string s = fmt::format("The date is {}", date(2012, 12, 9)); // s == "The date is 2012-12-9" -{fmt} only supports insertion operators that are defined in the same namespaces -as the types they format and can be found with the argument-dependent lookup. - .. doxygenfunction:: print(std::basic_ostream &os, const S &format_str, Args&&... args) .. _printf-api: