#2954: Use conjunction and disjunction substitute to make formatter specializations for ranges and maps more robust (especially for Visual Studio compiler family)
This commit is contained in:
parent
5eeeb317fc
commit
09f52a0007
@ -246,7 +246,7 @@ template <class Tuple, class F> void for_each(Tuple&& tup, F&& f) {
|
|||||||
for_each(indexes, std::forward<Tuple>(tup), std::forward<F>(f));
|
for_each(indexes, std::forward<Tuple>(tup), std::forward<F>(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FMT_MSC_VERSION
|
#if FMT_MSC_VERSION && FMT_MSC_VERSION < 1920
|
||||||
// Older MSVC doesn't get the reference type correctly for arrays.
|
// Older MSVC doesn't get the reference type correctly for arrays.
|
||||||
template <typename R> struct range_reference_type_impl {
|
template <typename R> struct range_reference_type_impl {
|
||||||
using type = decltype(*detail::range_begin(std::declval<R&>()));
|
using type = decltype(*detail::range_begin(std::declval<R&>()));
|
||||||
@ -396,15 +396,18 @@ template <typename R, typename Char>
|
|||||||
struct formatter<
|
struct formatter<
|
||||||
R, Char,
|
R, Char,
|
||||||
enable_if_t<
|
enable_if_t<
|
||||||
fmt::is_range<R, Char>::value
|
conjunction<fmt::is_range<R, Char>
|
||||||
// Workaround a bug in MSVC 2019 and earlier.
|
// Workaround a bug in MSVC 2017 and earlier.
|
||||||
#if !FMT_MSC_VERSION
|
#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1920
|
||||||
&&
|
,
|
||||||
(is_formattable<detail::uncvref_type<detail::maybe_const_range<R>>,
|
disjunction<
|
||||||
Char>::value ||
|
is_formattable<detail::uncvref_type<detail::maybe_const_range<R>>,
|
||||||
detail::has_fallback_formatter<
|
Char>,
|
||||||
detail::uncvref_type<detail::maybe_const_range<R>>, Char>::value)
|
detail::has_fallback_formatter<
|
||||||
|
detail::uncvref_type<detail::maybe_const_range<R>>, Char>
|
||||||
|
>
|
||||||
#endif
|
#endif
|
||||||
|
>::value
|
||||||
>> {
|
>> {
|
||||||
|
|
||||||
using range_type = detail::maybe_const_range<R>;
|
using range_type = detail::maybe_const_range<R>;
|
||||||
@ -457,14 +460,20 @@ struct formatter<
|
|||||||
template <typename T, typename Char>
|
template <typename T, typename Char>
|
||||||
struct formatter<
|
struct formatter<
|
||||||
T, Char,
|
T, Char,
|
||||||
enable_if_t<detail::is_map<T>::value
|
enable_if_t<conjunction<detail::is_map<T>
|
||||||
// Workaround a bug in MSVC 2019 and earlier.
|
// Workaround a bug in MSVC 2017 and earlier.
|
||||||
#if !FMT_MSC_VERSION
|
#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1920
|
||||||
&& (is_formattable<detail::uncvref_first_type<T>, Char>::value ||
|
,
|
||||||
detail::has_fallback_formatter<detail::uncvref_first_type<T>, Char>::value)
|
disjunction<
|
||||||
&& (is_formattable<detail::uncvref_second_type<T>, Char>::value ||
|
is_formattable<detail::uncvref_first_type<T>, Char>,
|
||||||
detail::has_fallback_formatter<detail::uncvref_second_type<T>, Char>::value)
|
detail::has_fallback_formatter<detail::uncvref_first_type<T>, Char>
|
||||||
|
>,
|
||||||
|
disjunction<
|
||||||
|
is_formattable<detail::uncvref_second_type<T>, Char>,
|
||||||
|
detail::has_fallback_formatter<detail::uncvref_second_type<T>, Char>
|
||||||
|
>
|
||||||
#endif
|
#endif
|
||||||
|
>::value
|
||||||
>> {
|
>> {
|
||||||
template <typename ParseContext>
|
template <typename ParseContext>
|
||||||
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user