mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 02:37:36 +02:00
Fix overload ambiguity in arg_mapper
This commit is contained in:
@ -1270,7 +1270,8 @@ template <typename Context> struct arg_mapper {
|
|||||||
FMT_CONSTEXPR FMT_INLINE auto map(const char_type* val) -> const char_type* {
|
FMT_CONSTEXPR FMT_INLINE auto map(const char_type* val) -> const char_type* {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
template <typename T, FMT_ENABLE_IF(is_string<T>::value)>
|
template <typename T,
|
||||||
|
FMT_ENABLE_IF(is_string<T>::value && !std::is_pointer<T>::value)>
|
||||||
FMT_CONSTEXPR FMT_INLINE auto map(const T& val)
|
FMT_CONSTEXPR FMT_INLINE auto map(const T& val)
|
||||||
-> basic_string_view<char_type> {
|
-> basic_string_view<char_type> {
|
||||||
static_assert(std::is_same<char_type, char_t<T>>::value,
|
static_assert(std::is_same<char_type, char_t<T>>::value,
|
||||||
@ -1324,9 +1325,8 @@ template <typename Context> struct arg_mapper {
|
|||||||
|
|
||||||
// We use SFINAE instead of a const T* parameter to avoid conflicting with
|
// We use SFINAE instead of a const T* parameter to avoid conflicting with
|
||||||
// the C array overload.
|
// the C array overload.
|
||||||
template <typename T>
|
template <typename T, FMT_ENABLE_IF(std::is_pointer<T>::value)>
|
||||||
FMT_CONSTEXPR auto map(T)
|
FMT_CONSTEXPR auto map(T) -> unformattable_pointer {
|
||||||
-> enable_if_t<std::is_pointer<T>::value, unformattable_pointer> {
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +87,10 @@ TEST(xchar_test, format) {
|
|||||||
EXPECT_EQ(L"abc1", fmt::format(L"{}c{}", L"ab", 1));
|
EXPECT_EQ(L"abc1", fmt::format(L"{}c{}", L"ab", 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(xchar_test, is_formattable) {
|
||||||
|
static_assert(!fmt::is_formattable<const wchar_t*>::value, "");
|
||||||
|
}
|
||||||
|
|
||||||
TEST(xchar_test, compile_time_string) {
|
TEST(xchar_test, compile_time_string) {
|
||||||
#if defined(FMT_USE_STRING_VIEW) && __cplusplus >= 201703L
|
#if defined(FMT_USE_STRING_VIEW) && __cplusplus >= 201703L
|
||||||
EXPECT_EQ(L"42", fmt::format(FMT_STRING(std::wstring_view(L"{}")), 42));
|
EXPECT_EQ(L"42", fmt::format(FMT_STRING(std::wstring_view(L"{}")), 42));
|
||||||
|
Reference in New Issue
Block a user