diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index 3a37c772a34b..972048fda782 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -68,7 +68,7 @@ template struct has_member_fn_begin_end_t : std::false_type {}; template -struct has_member_fn_begin_end_t().begin()), +struct has_member_fn_begin_end_t().begin()), decltype(std::declval().end())>> : std::true_type {}; @@ -99,15 +99,15 @@ struct has_mutable_begin_end : std::false_type {}; template struct has_const_begin_end< - T, - void_t< - decltype(detail::range_begin(std::declval&>())), - decltype(detail::range_end(std::declval&>()))>> + T, void_t&>())), + decltype(detail::range_end( + std::declval&>()))>> : std::true_type {}; template struct has_mutable_begin_end< - T, void_t())), + T, void_t())), decltype(detail::range_end(std::declval())), // the extra int here is because older versions of MSVC don't // SFINAE properly unless there are distinct types diff --git a/test/ranges-test.cc b/test/ranges-test.cc index 4a69ad75e62f..37a7aec8484e 100644 --- a/test/ranges-test.cc +++ b/test/ranges-test.cc @@ -742,3 +742,9 @@ TEST(ranges_test, movable_only_istream_iter_join) { EXPECT_EQ("1, 2, 3, 4, 5", fmt::format("{}", fmt::join(std::move(first), last, ", "))); } + +struct not_range { + void begin() const {} + void end() const {} +}; +static_assert(!fmt::is_formattable{}, "");