diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index 101bb3990e5e..dcdbb8998b5f 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -221,9 +221,23 @@ template void for_each(Tuple&& tup, F&& f) { for_each(indexes, std::forward(tup), std::forward(f)); } +#if FMT_MSC_VER +// older MSVC doesn't get the reference type correctly for arrays +template struct range_reference_type_impl { + using type = decltype(*detail::range_begin(std::declval())); +}; + +template struct range_reference_type_impl { + using type = T&; +}; + +template +using range_reference_type = typename range_reference_type_impl::type; +#else template using range_reference_type = - decltype(*detail::range_begin(std::declval())); + decltype(*detail::range_begin(std::declval())); +#endif // We don't use the Range's value_type for anything, but we do need the Range's // reference type, with cv-ref stripped