From 29c6000137dd94151b61e34fc9f658304878d71e Mon Sep 17 00:00:00 2001 From: NewbieOrange Date: Sat, 3 Sep 2022 12:08:07 +0800 Subject: [PATCH] Simplify is_variant_like_ check, fix compile error before GCC 11 (#3072) Co-authored-by: Vladislav Shchapov 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 c8b042a4..f1d1d120 100644 --- a/include/fmt/std.h +++ b/include/fmt/std.h @@ -101,14 +101,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 b9c15e02..77cf7934 100644 --- a/test/std-test.cc +++ b/test/std-test.cc @@ -75,6 +75,9 @@ 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 }