Fix formatting of objects convertible to string_view
This commit is contained in:
parent
e508e30800
commit
24d249b0b4
@ -570,7 +570,8 @@ FMT_MAKE_VALUE(cstring_type, signed char*, const signed char*)
|
||||
FMT_MAKE_VALUE(cstring_type, const signed char*, const signed char*)
|
||||
FMT_MAKE_VALUE(cstring_type, unsigned char*, const unsigned char*)
|
||||
FMT_MAKE_VALUE(cstring_type, const unsigned char*, const unsigned char*)
|
||||
FMT_MAKE_VALUE(string_type, basic_string_view<Char>, basic_string_view<Char>)
|
||||
FMT_MAKE_VALUE(string_type, basic_string_view<typename C::char_type>,
|
||||
basic_string_view<Char>)
|
||||
FMT_MAKE_VALUE(string_type, const std::basic_string<typename C::char_type>&,
|
||||
basic_string_view<Char>)
|
||||
FMT_MAKE_VALUE(pointer_type, void*, const void*)
|
||||
@ -595,6 +596,7 @@ inline typename std::enable_if<
|
||||
template <typename C, typename T, typename Char = typename C::char_type>
|
||||
inline typename std::enable_if<
|
||||
!convert_to_int<T, Char>::value &&
|
||||
!std::is_convertible<T, basic_string_view<Char>>::value &&
|
||||
!std::is_convertible<T, std::basic_string<Char>>::value,
|
||||
typed_value<C, custom_type>>::type
|
||||
make_value(const T &val) { return val; }
|
||||
|
@ -1223,6 +1223,14 @@ TEST(FormatterTest, FormatConvertibleToString) {
|
||||
EXPECT_EQ("foo", format("{}", ConvertibleToString()));
|
||||
}
|
||||
|
||||
struct ConvertibleToStringView {
|
||||
operator fmt::string_view() const { return "foo"; }
|
||||
};
|
||||
|
||||
TEST(FormatterTest, FormatConvertibleToStringView) {
|
||||
EXPECT_EQ("foo", format("{}", ConvertibleToStringView()));
|
||||
}
|
||||
|
||||
namespace fmt {
|
||||
template <>
|
||||
struct formatter<Date> {
|
||||
|
Loading…
Reference in New Issue
Block a user