diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index c04655cc..dd005fa1 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -72,10 +72,11 @@ class is_streamable { template struct is_streamable< T, Char, - enable_if_t::value || std::is_array::value || - std::is_same::value || - (std::is_convertible::value && - !std::is_enum::value)>> : std::false_type {}; + enable_if_t< + std::is_arithmetic::value || std::is_array::value || + std::is_pointer::value || std::is_same::value || + (std::is_convertible::value && !std::is_enum::value)>> + : std::false_type {}; // Write the content of buf to os. // It is a separate function rather than a part of vprint to simplify testing. diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index acff1574..ab78a851 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -582,9 +582,9 @@ struct formatter< T, Char, enable_if_t< fmt::is_range::value -// Workaround a bug in MSVC 2017 and earlier. -#if !FMT_MSC_VER || FMT_MSC_VER >= 1927 - && (has_formatter, format_context>::value || +// Workaround a bug in MSVC 2019 and earlier. +#if !FMT_MSC_VER + && (is_formattable, Char>::value || detail::has_fallback_formatter, Char>::value) #endif >> { diff --git a/test/ranges-test.cc b/test/ranges-test.cc index 7808cdbd..d918ad59 100644 --- a/test/ranges-test.cc +++ b/test/ranges-test.cc @@ -190,7 +190,14 @@ TEST(ranges_test, range) { EXPECT_EQ(fmt::format("{}", z), "[0, 0, 0]"); } -#if !FMT_MSC_VER || FMT_MSC_VER >= 1927 +enum class test_enum { foo }; + +TEST(ranges_test, enum_range) { + auto v = std::vector{test_enum::foo}; + EXPECT_EQ(fmt::format("{}", v), "[0]"); +} + +#if !FMT_MSC_VER struct unformattable {}; TEST(ranges_test, unformattable_range) {