From 909e42dfc3ca4c98251549146d4d9efca25fd6f9 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 10 Jun 2022 14:53:48 -0700 Subject: [PATCH] Backport a fix to C++20 partial specialization issue Summary: Backport a fix to https://github.com/fmtlib/fmt/issues/2769. Reviewed By: aandreyeu Differential Revision: D37077479 fbshipit-source-id: 6f9d716c47784717c4aa36eba89498639eb3503a --- deps/fmt/include/fmt/core.h | 22 ++++++++++++++++++++++ deps/fmt/include/fmt/format.h | 22 ---------------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/deps/fmt/include/fmt/core.h b/deps/fmt/include/fmt/core.h index 3211d598..b4272795 100644 --- a/deps/fmt/include/fmt/core.h +++ b/deps/fmt/include/fmt/core.h @@ -3044,6 +3044,28 @@ 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::byte, unsigned char); +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/deps/fmt/include/fmt/format.h b/deps/fmt/include/fmt/format.h index 9752ca9d..ee23ad76 100644 --- a/deps/fmt/include/fmt/format.h +++ b/deps/fmt/include/fmt/format.h @@ -2581,28 +2581,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::byte, unsigned char); -FMT_FORMAT_AS(detail::std_string_view, basic_string_view); - template struct formatter : formatter { template