diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index 280d1c57..8b7c9aad 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -391,19 +391,21 @@ template using maybe_const_range = conditional_t::value, const R, R>; +// is_nonrecursive_range depends on fmt::is_range::value == true. +// It exists to ensure short-circuit evaluation in the constraint of the +// formatter specialization below. A similar approach is used in +// https://wg21.link/p2286. template -struct is_not_recursive_range : bool_constant< - !std::is_same, R>::value> {}; +struct is_nonrecursive_range : bool_constant< + !std::is_same, R>::value> {}; +// is_formattable_delayed depends on is_nonrecursive_range::value == true. +// It exists to ensure short-circuit evaluation in the constraint of the +// formatter specialization below. template -struct is_formattable_delayed : is_formattable< - detail::uncvref_type>, Char> { -}; - -template -struct has_fallback_formatter_delayed : detail::has_fallback_formatter< - detail::uncvref_type>, Char> { -}; +struct is_formattable_delayed : disjunction< + is_formattable>, Char>, + has_fallback_formatter>, Char>> {}; } // namespace detail @@ -412,14 +414,11 @@ struct formatter< R, Char, enable_if_t< conjunction, - detail::is_not_recursive_range + detail::is_nonrecursive_range // Workaround a bug in MSVC 2015 and earlier. #if !FMT_MSC_VERSION || FMT_MSC_VERSION > 1900 , - disjunction< - detail::is_formattable_delayed, - detail::has_fallback_formatter_delayed - > + detail::is_formattable_delayed #endif >::value >> {