Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Feb 13, 2022
1 parent 083510f commit c48353c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <fmt/ostream.h>

Expand All @@ -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));
// 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)

.. _printf-api:
Expand Down

0 comments on commit c48353c

Please sign in to comment.