diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index e6540108..cf0d41aa 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -242,13 +242,16 @@ struct formatter::value>> { } }; -template struct is_range { +template struct is_range { static FMT_CONSTEXPR_DECL const bool value = - internal::is_range_::value && !internal::is_like_std_string::value; + internal::is_range_::value && + !internal::is_like_std_string::value && + !std::is_convertible>::value; }; template -struct formatter::value>> { +struct formatter::value>> { formatting_range formatting; template diff --git a/test/ranges-test.cc b/test/ranges-test.cc index acddd0d5..7d4b6d24 100644 --- a/test/ranges-test.cc +++ b/test/ranges-test.cc @@ -87,5 +87,16 @@ TEST(RangesTest, FormatTo) { EXPECT_STREQ(buf, "{1, 2, 3}"); } +struct path_like { + const path_like* begin() const; + const path_like* end() const; + + operator std::string() const; +}; + +TEST(RangesTest, PathLike) { + EXPECT_FALSE((fmt::is_range::value)); +} + #endif // (__cplusplus > 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG > // 201402L && _MSC_VER >= 1910)