From 6d6aaef6a2005114c62a53f8098ca855806367db Mon Sep 17 00:00:00 2001 From: NewbieOrange Date: Thu, 1 Sep 2022 17:11:43 +0000 Subject: [PATCH] Simplify is_variant_like_ check, fix compile error before GCC 11 Co-authored-by: Vladislav Shchapov --- include/fmt/std.h | 10 ++++------ test/std-test.cc | 3 +++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/fmt/std.h b/include/fmt/std.h index 41d2b2838b6d..2511d5390ec6 100644 --- a/include/fmt/std.h +++ b/include/fmt/std.h @@ -100,14 +100,12 @@ template using variant_index_sequence = std::make_index_sequence::value>; -// variant_size and variant_alternative check. -template +template struct is_variant_like_ : std::false_type {}; -template -struct is_variant_like_::value)>> - : std::true_type {}; +template +struct is_variant_like_> : std::true_type {}; -// formattable element check +// formattable element check. template class is_variant_formattable_ { template static std::conjunction< diff --git a/test/std-test.cc b/test/std-test.cc index c22b3e38fb39..76de163b82e7 100644 --- a/test/std-test.cc +++ b/test/std-test.cc @@ -75,5 +75,8 @@ TEST(std_test, variant) { EXPECT_EQ(fmt::format("{}", v4), "variant(monostate)"); EXPECT_EQ(fmt::format("{}", v5), "variant(\"yes, this is variant\")"); + + volatile int i = 42; // Test compile error before GCC 11 described in #3068. + EXPECT_EQ(fmt::format("{}", i), "42"); #endif }