From 1266c2b6003e6391046bbab57dcf20293e25dedd Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 17 Oct 2021 08:58:41 -0700 Subject: [PATCH] Fix handling of exotic character types --- include/fmt/core.h | 10 ++++++++-- test/core-test.cc | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index a8742c5f..5dc4e352 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1285,8 +1285,14 @@ template struct arg_mapper { FMT_CONSTEXPR FMT_INLINE auto map(T val) -> char_type { return val; } - template ::value && - !std::is_same::value)> + template ::value || +#ifdef __cpp_char8_t + std::is_same::value || +#endif + std::is_same::value || + std::is_same::value) && + !std::is_same::value, + int> = 0> FMT_CONSTEXPR FMT_INLINE auto map(T) -> unformattable_char { return {}; } diff --git a/test/core-test.cc b/test/core-test.cc index c99098cb..5cf9dbd8 100644 --- a/test/core-test.cc +++ b/test/core-test.cc @@ -739,6 +739,11 @@ TEST(core_test, is_formattable) { static_assert(fmt::is_formattable::value, ""); static_assert(fmt::is_formattable::value, ""); static_assert(!fmt::is_formattable::value, ""); +#ifdef __cpp_char8_t + static_assert(!fmt::is_formattable::value, ""); +#endif + static_assert(!fmt::is_formattable::value, ""); + static_assert(!fmt::is_formattable::value, ""); static_assert(!fmt::is_formattable::value, ""); static_assert(!fmt::is_formattable::value, ""); static_assert(!fmt::is_formattable>::value,