mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-31 11:17:35 +02:00
Remove problematic constructibility check
This commit is contained in:
@ -1337,20 +1337,19 @@ template <typename Context> struct arg_mapper {
|
|||||||
}
|
}
|
||||||
template <typename T,
|
template <typename T,
|
||||||
FMT_ENABLE_IF(
|
FMT_ENABLE_IF(
|
||||||
std::is_constructible<basic_string_view<char_type>, T>::value &&
|
std::is_convertible<T, basic_string_view<char_type>>::value &&
|
||||||
!is_string<T>::value && !has_formatter<T, Context>::value &&
|
!is_string<T>::value && !has_formatter<T, Context>::value &&
|
||||||
!has_fallback_formatter<T, char_type>::value)>
|
!has_fallback_formatter<T, char_type>::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> {
|
||||||
return basic_string_view<char_type>(val);
|
return basic_string_view<char_type>(val);
|
||||||
}
|
}
|
||||||
template <
|
template <typename T,
|
||||||
typename T,
|
FMT_ENABLE_IF(
|
||||||
FMT_ENABLE_IF(
|
std::is_convertible<T, std_string_view<char_type>>::value &&
|
||||||
std::is_constructible<std_string_view<char_type>, T>::value &&
|
!std::is_convertible<T, basic_string_view<char_type>>::value &&
|
||||||
!std::is_constructible<basic_string_view<char_type>, T>::value &&
|
!is_string<T>::value && !has_formatter<T, Context>::value &&
|
||||||
!is_string<T>::value && !has_formatter<T, Context>::value &&
|
!has_fallback_formatter<T, char_type>::value)>
|
||||||
!has_fallback_formatter<T, char_type>::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> {
|
||||||
return std_string_view<char_type>(val);
|
return std_string_view<char_type>(val);
|
||||||
|
@ -890,7 +890,10 @@ struct explicitly_convertible_to_string_view {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TEST(core_test, format_explicitly_convertible_to_string_view) {
|
TEST(core_test, format_explicitly_convertible_to_string_view) {
|
||||||
EXPECT_EQ("foo", fmt::format("{}", explicitly_convertible_to_string_view()));
|
// Types explicitly convertible to string_view are not formattable by
|
||||||
|
// default because it may introduce ODR violations.
|
||||||
|
static_assert(
|
||||||
|
!fmt::is_formattable<explicitly_convertible_to_string_view>::value, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef FMT_USE_STRING_VIEW
|
# ifdef FMT_USE_STRING_VIEW
|
||||||
@ -899,8 +902,11 @@ struct explicitly_convertible_to_std_string_view {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TEST(core_test, format_explicitly_convertible_to_std_string_view) {
|
TEST(core_test, format_explicitly_convertible_to_std_string_view) {
|
||||||
EXPECT_EQ("foo",
|
// Types explicitly convertible to string_view are not formattable by
|
||||||
fmt::format("{}", explicitly_convertible_to_std_string_view()));
|
// default because it may introduce ODR violations.
|
||||||
|
static_assert(
|
||||||
|
!fmt::is_formattable<explicitly_convertible_to_std_string_view>::value,
|
||||||
|
"");
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -133,8 +133,8 @@ TEST(ranges_test, path_like) {
|
|||||||
struct string_like {
|
struct string_like {
|
||||||
const char* begin();
|
const char* begin();
|
||||||
const char* end();
|
const char* end();
|
||||||
explicit operator fmt::string_view() const { return "foo"; }
|
operator fmt::string_view() const { return "foo"; }
|
||||||
explicit operator std::string_view() const { return "foo"; }
|
operator std::string_view() const { return "foo"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST(ranges_test, format_string_like) {
|
TEST(ranges_test, format_string_like) {
|
||||||
|
@ -72,8 +72,10 @@ struct explicitly_convertible_to_wstring_view {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TEST(xchar_test, format_explicitly_convertible_to_wstring_view) {
|
TEST(xchar_test, format_explicitly_convertible_to_wstring_view) {
|
||||||
EXPECT_EQ(L"foo",
|
// Types explicitly convertible to wstring_view are not formattable by
|
||||||
fmt::format(L"{}", explicitly_convertible_to_wstring_view()));
|
// default because it may introduce ODR violations.
|
||||||
|
static_assert(
|
||||||
|
!fmt::is_formattable<explicitly_convertible_to_wstring_view>::value, "");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user