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: