Update docs

This commit is contained in:
Victor Zverovich 2022-02-13 07:40:43 -08:00
parent 083510f0f0
commit c48353cb75

View File

@ -493,7 +493,9 @@ System APIs
======================== ========================
``fmt/ostream.h`` provides ``std::ostream`` support including formatting of ``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 <fmt/ostream.h> #include <fmt/ostream.h>
@ -507,14 +509,11 @@ user-defined types that have an overloaded insertion operator (``operator<<``)::
} }
}; };
template <> struct fmt::formatter<date> : ostream_formatter<date> {}; template <> struct fmt::formatter<date> : ostream_formatter {};
std::string s = fmt::format("The date is {}", date(2012, 12, 9)); std::string s = fmt::format("The date is {}", date(2012, 12, 9));
// s == "The date is 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<Char> &os, const S &format_str, Args&&... args) .. doxygenfunction:: print(std::basic_ostream<Char> &os, const S &format_str, Args&&... args)
.. _printf-api: .. _printf-api: