c++11 use formatting user-defined types (#1721)

This commit is contained in:
文佳鹏 2020-06-12 01:10:39 +08:00 committed by GitHub
parent 100e8af08a
commit f904e8a1b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -136,6 +136,7 @@ template and implement ``parse`` and ``format`` methods::
// Parses format specifications of the form ['f' | 'e']. // Parses format specifications of the form ['f' | 'e'].
constexpr auto parse(format_parse_context& ctx) { constexpr auto parse(format_parse_context& ctx) {
// auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) //c++11
// [ctx.begin(), ctx.end()) is a character range that contains a part of // [ctx.begin(), ctx.end()) is a character range that contains a part of
// the format string starting from the format specifications to be parsed, // the format string starting from the format specifications to be parsed,
// e.g. in // e.g. in
@ -163,6 +164,7 @@ template and implement ``parse`` and ``format`` methods::
// stored in this formatter. // stored in this formatter.
template <typename FormatContext> template <typename FormatContext>
auto format(const point& p, FormatContext& ctx) { auto format(const point& p, FormatContext& ctx) {
// auto format(const point &p, FormatContext &ctx) -> decltype(ctx.out()) //c++11
// ctx.out() is an output iterator to write to. // ctx.out() is an output iterator to write to.
return format_to( return format_to(
ctx.out(), ctx.out(),