Fix enable_ifs for map formatter (#2944)

This commit is contained in:
Jonathan W
2022-06-23 17:24:11 +02:00
committed by GitHub
parent 7c56e11ecf
commit e8bd2a804d

View File

@ -269,6 +269,14 @@ using range_reference_type =
template <typename Range> template <typename Range>
using uncvref_type = remove_cvref_t<range_reference_type<Range>>; using uncvref_type = remove_cvref_t<range_reference_type<Range>>;
template <typename Range>
using uncvref_first_type = remove_cvref_t<
decltype(std::declval<range_reference_type<Range>>().first)>;
template <typename Range>
using uncvref_second_type = remove_cvref_t<
decltype(std::declval<range_reference_type<Range>>().second)>;
template <typename OutputIt> OutputIt write_delimiter(OutputIt out) { template <typename OutputIt> OutputIt write_delimiter(OutputIt out) {
*out++ = ','; *out++ = ',';
*out++ = ' '; *out++ = ' ';
@ -452,11 +460,12 @@ struct formatter<
enable_if_t<detail::is_map<T>::value enable_if_t<detail::is_map<T>::value
// Workaround a bug in MSVC 2019 and earlier. // Workaround a bug in MSVC 2019 and earlier.
#if !FMT_MSC_VERSION #if !FMT_MSC_VERSION
&& (is_formattable<detail::uncvref_type<T>, Char>::value || && (is_formattable<detail::uncvref_first_type<T>, Char>::value ||
detail::has_fallback_formatter<detail::uncvref_type<T>, detail::has_fallback_formatter<detail::uncvref_first_type<T>, Char>::value)
Char>::value) && (is_formattable<detail::uncvref_second_type<T>, Char>::value ||
detail::has_fallback_formatter<detail::uncvref_second_type<T>, Char>::value)
#endif #endif
>> { >> {
template <typename ParseContext> template <typename ParseContext>
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
return ctx.begin(); return ctx.begin();