From a1ea3e015b1c07e740e9b69e7625dcafce4a23c7 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 16 Feb 2022 07:37:00 -0800 Subject: [PATCH] Move built-in formatter specialization to core --- include/fmt/core.h | 21 +++++++++++++++++++++ include/fmt/format.h | 21 --------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 2a0c9ad7..8d7ada45 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -3027,6 +3027,27 @@ struct formatter decltype(ctx.out()); }; +#define FMT_FORMAT_AS(Type, Base) \ + template \ + struct formatter : formatter { \ + template \ + auto format(Type const& val, FormatContext& ctx) const \ + -> decltype(ctx.out()) { \ + return formatter::format(static_cast(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, basic_string_view); +FMT_FORMAT_AS(std::nullptr_t, const void*); +FMT_FORMAT_AS(detail::std_string_view, basic_string_view); + template struct basic_runtime { basic_string_view str; }; /** A compile-time format string. */ diff --git a/include/fmt/format.h b/include/fmt/format.h index 00f28476..84b9e7ae 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2762,27 +2762,6 @@ formatter(ctx.out(), val, specs_, ctx.locale()); } -#define FMT_FORMAT_AS(Type, Base) \ - template \ - struct formatter : formatter { \ - template \ - auto format(Type const& val, FormatContext& ctx) const \ - -> decltype(ctx.out()) { \ - return formatter::format(static_cast(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, basic_string_view); -FMT_FORMAT_AS(std::nullptr_t, const void*); -FMT_FORMAT_AS(detail::std_string_view, basic_string_view); - template struct formatter : formatter { template