forked from fmtlib/fmt
Move built-in formatter specialization to core
This commit is contained in:
@ -3027,6 +3027,27 @@ struct formatter<T, Char,
|
|||||||
-> decltype(ctx.out());
|
-> decltype(ctx.out());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define FMT_FORMAT_AS(Type, Base) \
|
||||||
|
template <typename Char> \
|
||||||
|
struct formatter<Type, Char> : formatter<Base, Char> { \
|
||||||
|
template <typename FormatContext> \
|
||||||
|
auto format(Type const& val, FormatContext& ctx) const \
|
||||||
|
-> decltype(ctx.out()) { \
|
||||||
|
return formatter<Base, Char>::format(static_cast<Base>(val), ctx); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
FMT_FORMAT_AS(signed char, int);
|
||||||
|
FMT_FORMAT_AS(unsigned char, unsigned);
|
||||||
|
FMT_FORMAT_AS(short, int);
|
||||||
|
FMT_FORMAT_AS(unsigned short, unsigned);
|
||||||
|
FMT_FORMAT_AS(long, long long);
|
||||||
|
FMT_FORMAT_AS(unsigned long, unsigned long long);
|
||||||
|
FMT_FORMAT_AS(Char*, const Char*);
|
||||||
|
FMT_FORMAT_AS(std::basic_string<Char>, basic_string_view<Char>);
|
||||||
|
FMT_FORMAT_AS(std::nullptr_t, const void*);
|
||||||
|
FMT_FORMAT_AS(detail::std_string_view<Char>, basic_string_view<Char>);
|
||||||
|
|
||||||
template <typename Char> struct basic_runtime { basic_string_view<Char> str; };
|
template <typename Char> struct basic_runtime { basic_string_view<Char> str; };
|
||||||
|
|
||||||
/** A compile-time format string. */
|
/** A compile-time format string. */
|
||||||
|
@ -2762,27 +2762,6 @@ formatter<T, Char,
|
|||||||
return detail::write<Char>(ctx.out(), val, specs_, ctx.locale());
|
return detail::write<Char>(ctx.out(), val, specs_, ctx.locale());
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FMT_FORMAT_AS(Type, Base) \
|
|
||||||
template <typename Char> \
|
|
||||||
struct formatter<Type, Char> : formatter<Base, Char> { \
|
|
||||||
template <typename FormatContext> \
|
|
||||||
auto format(Type const& val, FormatContext& ctx) const \
|
|
||||||
-> decltype(ctx.out()) { \
|
|
||||||
return formatter<Base, Char>::format(static_cast<Base>(val), ctx); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_FORMAT_AS(signed char, int);
|
|
||||||
FMT_FORMAT_AS(unsigned char, unsigned);
|
|
||||||
FMT_FORMAT_AS(short, int);
|
|
||||||
FMT_FORMAT_AS(unsigned short, unsigned);
|
|
||||||
FMT_FORMAT_AS(long, long long);
|
|
||||||
FMT_FORMAT_AS(unsigned long, unsigned long long);
|
|
||||||
FMT_FORMAT_AS(Char*, const Char*);
|
|
||||||
FMT_FORMAT_AS(std::basic_string<Char>, basic_string_view<Char>);
|
|
||||||
FMT_FORMAT_AS(std::nullptr_t, const void*);
|
|
||||||
FMT_FORMAT_AS(detail::std_string_view<Char>, basic_string_view<Char>);
|
|
||||||
|
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
struct formatter<void*, Char> : formatter<const void*, Char> {
|
struct formatter<void*, Char> : formatter<const void*, Char> {
|
||||||
template <typename FormatContext>
|
template <typename FormatContext>
|
||||||
|
Reference in New Issue
Block a user