Skip to content

Commit

Permalink
Trying to add a workaround for MSVC.
Browse files Browse the repository at this point in the history
  • Loading branch information
brevzin committed Jan 6, 2022
1 parent 99b4b4e commit 9b636f6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/fmt/ranges.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,23 @@ template <class Tuple, class F> void for_each(Tuple&& tup, F&& f) {
for_each(indexes, std::forward<Tuple>(tup), std::forward<F>(f));
}

#if FMT_MSC_VER
// older MSVC doesn't get the reference type correctly for arrays
template <typename R> struct range_reference_type_impl {
using type = decltype(*detail::range_begin(std::declval<Range>()));
};

template <typename T, std::size_t N> struct range_reference_type_impl<T[N]> {
using type = T&;
};

template <typename T>
using range_reference_type = typename range_reference_type_impl<T>::type;
#else
template <typename Range>
using range_reference_type =
decltype(*detail::range_begin(std::declval<Range>()));
#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
Expand Down

0 comments on commit 9b636f6

Please sign in to comment.