Commit 1266c2b6 authored by Victor Zverovich's avatar Victor Zverovich

Fix handling of exotic character types

parent 684e2fdc
...@@ -1285,8 +1285,14 @@ template <typename Context> struct arg_mapper { ...@@ -1285,8 +1285,14 @@ template <typename Context> struct arg_mapper {
FMT_CONSTEXPR FMT_INLINE auto map(T val) -> char_type { FMT_CONSTEXPR FMT_INLINE auto map(T val) -> char_type {
return val; return val;
} }
template <typename T, FMT_ENABLE_IF(std::is_same<T, wchar_t>::value && template <typename T, enable_if_t<(std::is_same<T, wchar_t>::value ||
!std::is_same<wchar_t, char_type>::value)> #ifdef __cpp_char8_t
std::is_same<T, char8_t>::value ||
#endif
std::is_same<T, char16_t>::value ||
std::is_same<T, char32_t>::value) &&
!std::is_same<T, char_type>::value,
int> = 0>
FMT_CONSTEXPR FMT_INLINE auto map(T) -> unformattable_char { FMT_CONSTEXPR FMT_INLINE auto map(T) -> unformattable_char {
return {}; return {};
} }
......
...@@ -739,6 +739,11 @@ TEST(core_test, is_formattable) { ...@@ -739,6 +739,11 @@ TEST(core_test, is_formattable) {
static_assert(fmt::is_formattable<const signed char*>::value, ""); static_assert(fmt::is_formattable<const signed char*>::value, "");
static_assert(fmt::is_formattable<const unsigned char*>::value, ""); static_assert(fmt::is_formattable<const unsigned char*>::value, "");
static_assert(!fmt::is_formattable<wchar_t>::value, ""); static_assert(!fmt::is_formattable<wchar_t>::value, "");
#ifdef __cpp_char8_t
static_assert(!fmt::is_formattable<char8_t>::value, "");
#endif
static_assert(!fmt::is_formattable<char16_t>::value, "");
static_assert(!fmt::is_formattable<char32_t>::value, "");
static_assert(!fmt::is_formattable<const wchar_t*>::value, ""); static_assert(!fmt::is_formattable<const wchar_t*>::value, "");
static_assert(!fmt::is_formattable<const wchar_t[3]>::value, ""); static_assert(!fmt::is_formattable<const wchar_t[3]>::value, "");
static_assert(!fmt::is_formattable<fmt::basic_string_view<wchar_t>>::value, static_assert(!fmt::is_formattable<fmt::basic_string_view<wchar_t>>::value,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment