diff --git a/include/fmt/base.h b/include/fmt/base.h index f440cffd..ceb98455 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -441,7 +441,8 @@ struct is_std_string_like : std::false_type {}; template struct is_std_string_like().find_first_of( typename T::value_type(), 0))>> - : std::true_type {}; + : std::is_convertible().data()), + const typename T::value_type*> {}; // Returns true iff the literal encoding is UTF-8. constexpr auto is_utf8_enabled() -> bool { diff --git a/test/format-test.cc b/test/format-test.cc index 257b6ead..a9ef19fc 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -2420,3 +2420,25 @@ TEST(format_test, formatter_overrides_implicit_conversion) { EXPECT_EQ(fmt::format("{}", convertible_to_int()), "x"); EXPECT_EQ(fmt::format("{}", convertible_to_cstring()), "y"); } + +struct ustring { + using value_type = unsigned; + + auto find_first_of(value_type, size_t) const -> size_t; + + auto data() const -> const char*; + auto size() const -> size_t; +}; + +FMT_BEGIN_NAMESPACE +template <> struct formatter : formatter { + auto format(const ustring&, format_context& ctx) const + -> decltype(ctx.out()) { + return formatter::format("ustring", ctx); + } +}; +FMT_END_NAMESPACE + +TEST(format_test, ustring) { + EXPECT_EQ(fmt::format("{}", ustring()), "ustring"); +}