From aec3bb5d0a0f01a8bdf97b6a68fc2458732a9b0d Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 3 Sep 2022 06:35:55 -0700 Subject: [PATCH] Workaround C complex.h idiocy --- include/fmt/ranges.h | 14 +++++++------- include/fmt/std.h | 9 ++++----- test/core-test.cc | 2 -- test/enforce-checks-test.cc | 2 ++ 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index dea7d60d..2105a668 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -211,16 +211,16 @@ class is_tuple_formattable_ { static constexpr const bool value = false; }; template class is_tuple_formattable_ { - template - static std::true_type check2(index_sequence, - integer_sequence); + template + static std::true_type check2(index_sequence, + integer_sequence); static std::false_type check2(...); - template + template static decltype(check2( - index_sequence{}, + index_sequence{}, integer_sequence< - bool, (is_formattable::type, - C>::value)...>{})) check(index_sequence); + bool, (is_formattable::type, + C>::value)...>{})) check(index_sequence); public: static constexpr const bool value = diff --git a/include/fmt/std.h b/include/fmt/std.h index f1d1d120..63dbebe3 100644 --- a/include/fmt/std.h +++ b/include/fmt/std.h @@ -101,17 +101,16 @@ template using variant_index_sequence = std::make_index_sequence::value>; -template -struct is_variant_like_ : std::false_type {}; +template struct is_variant_like_ : std::false_type {}; template struct is_variant_like_> : std::true_type {}; // formattable element check. template class is_variant_formattable_ { - template + template static std::conjunction< - is_formattable, C>...> - check(std::index_sequence); + is_formattable, C>...> + check(std::index_sequence); public: static constexpr const bool value = diff --git a/test/core-test.cc b/test/core-test.cc index c76dc161..96cde1ed 100644 --- a/test/core-test.cc +++ b/test/core-test.cc @@ -9,9 +9,7 @@ #include "test-assert.h" // clang-format on -#define I 42 // simulate https://en.cppreference.com/w/c/numeric/complex/I #include "fmt/core.h" -#undef I #include // std::copy_n #include // INT_MAX diff --git a/test/enforce-checks-test.cc b/test/enforce-checks-test.cc index c77cb142..960a7fcd 100644 --- a/test/enforce-checks-test.cc +++ b/test/enforce-checks-test.cc @@ -8,12 +8,14 @@ #include #include +#define I 42 // simulate https://en.cppreference.com/w/c/numeric/complex/I #include "fmt/chrono.h" #include "fmt/color.h" #include "fmt/format.h" #include "fmt/ostream.h" #include "fmt/ranges.h" #include "fmt/xchar.h" +#undef I // Exercise the API to verify that everything we expect to can compile. void test_format_api() {