Fix a couple of deprecated things.

This commit is contained in:
Tommy Nguyen 2019-03-31 12:47:37 -04:00
parent 018d8b57f6
commit b8f911fba7
No known key found for this signature in database
GPG Key ID: DB7FA8161647D196

View File

@ -111,11 +111,13 @@ template and implement ``parse`` and ``format`` methods::
template <>
struct formatter<point> {
template <typename ParseContext>
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); }
constexpr auto parse(ParseContext &ctx) -> decltype(ctx.begin()) {
return ctx.begin();
}
template <typename FormatContext>
auto format(const point &p, FormatContext &ctx) {
return format_to(ctx.begin(), "({:.1f}, {:.1f})", p.x, p.y);
auto format(const point &p, FormatContext &ctx) -> decltype(ctx.out()) {
return format_to(ctx.out(), "({:.1f}, {:.1f})", p.x, p.y);
}
};
}
@ -129,7 +131,7 @@ Then you can pass objects of type ``point`` to any formatting function::
In the example above the ``formatter<point>::parse`` function ignores the
contents of the format string referred to by ``ctx.begin()`` so the object will
always be formatted in the same way. See ``formatter<tm>::parse`` in
:file:`fmt/time.h` for an advanced example of how to parse the format string and
:file:`fmt/chrono.h` for an advanced example of how to parse the format string and
customize the formatted output.
You can also reuse existing formatters, for example::