From 26a28441d3aca9e412db7062d7bdfb5c4be2984d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kr=C3=BCgler?= Date: Wed, 6 Jul 2022 19:53:40 +0200 Subject: [PATCH] #2968: Introduce additional compile-time predicate to detect recursive ranges and reject them in formatter specialization for ranges. In addition, introduce additional wrapper traits for the individual logical operands of the complete range constraints --- include/fmt/ranges.h | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index 10429fc8..0010f49e 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -390,23 +390,33 @@ using range_formatter_type = conditional_t< template using maybe_const_range = conditional_t::value, const R, R>; + +template +struct is_not_recursive_range : std::bool_constant< + !std::is_same, R>::value> {}; + +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> { +}; + } // namespace detail template struct formatter< R, Char, enable_if_t< - conjunction -// Workaround a bug in MSVC 2017 and earlier. -#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1920 - , - disjunction< - is_formattable>, - Char>, - detail::has_fallback_formatter< - detail::uncvref_type>, Char> - > -#endif + conjunction, + detail::is_not_recursive_range, + disjunction< + detail::is_formattable_delayed, + detail::has_fallback_formatter_delayed + > >::value >> {