diff --git a/include/fmt/core.h b/include/fmt/core.h index eebce949..0b91e0d5 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -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, basic_string_view) +FMT_MAKE_VALUE(string_type, basic_string_view, + basic_string_view) FMT_MAKE_VALUE(string_type, const std::basic_string&, basic_string_view) FMT_MAKE_VALUE(pointer_type, void*, const void*) @@ -595,6 +596,7 @@ inline typename std::enable_if< template inline typename std::enable_if< !convert_to_int::value && + !std::is_convertible>::value && !std::is_convertible>::value, typed_value>::type make_value(const T &val) { return val; } diff --git a/test/format-test.cc b/test/format-test.cc index af4018dc..d689b15f 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -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 {