From 6d597e39c3397da39e8dd9b84df958e8589afa1a Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Thu, 26 Aug 2021 16:54:27 -0700 Subject: [PATCH] Fix overload ambiguity in arg_mapper --- include/fmt/core.h | 8 ++++---- test/xchar-test.cc | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 3097feee..bb67a9ea 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1270,7 +1270,8 @@ template struct arg_mapper { FMT_CONSTEXPR FMT_INLINE auto map(const char_type* val) -> const char_type* { return val; } - template ::value)> + template ::value && !std::is_pointer::value)> FMT_CONSTEXPR FMT_INLINE auto map(const T& val) -> basic_string_view { static_assert(std::is_same>::value, @@ -1324,9 +1325,8 @@ template struct arg_mapper { // We use SFINAE instead of a const T* parameter to avoid conflicting with // the C array overload. - template - FMT_CONSTEXPR auto map(T) - -> enable_if_t::value, unformattable_pointer> { + template ::value)> + FMT_CONSTEXPR auto map(T) -> unformattable_pointer { return {}; } diff --git a/test/xchar-test.cc b/test/xchar-test.cc index 4e837aab..106840e6 100644 --- a/test/xchar-test.cc +++ b/test/xchar-test.cc @@ -87,6 +87,10 @@ TEST(xchar_test, format) { EXPECT_EQ(L"abc1", fmt::format(L"{}c{}", L"ab", 1)); } +TEST(xchar_test, is_formattable) { + static_assert(!fmt::is_formattable::value, ""); +} + TEST(xchar_test, compile_time_string) { #if defined(FMT_USE_STRING_VIEW) && __cplusplus >= 201703L EXPECT_EQ(L"42", fmt::format(FMT_STRING(std::wstring_view(L"{}")), 42));