mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-26 00:21:13 +00:00
Move built-in formatter specialization to core
This commit is contained in:
parent
161059dd98
commit
a1ea3e015b
@ -3027,6 +3027,27 @@ struct formatter<T, Char,
|
||||
-> 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; };
|
||||
|
||||
/** A compile-time format string. */
|
||||
|
@ -2762,27 +2762,6 @@ formatter<T, Char,
|
||||
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>
|
||||
struct formatter<void*, Char> : formatter<const void*, Char> {
|
||||
template <typename FormatContext>
|
||||
|
Loading…
Reference in New Issue
Block a user