mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 10:47:35 +02:00
Simplify is_variant_like_ check, fix compile error before GCC 11 (#3072)
Co-authored-by: Vladislav Shchapov <vladislav@shchapov.ru> Co-authored-by: Vladislav Shchapov <vladislav@shchapov.ru>
This commit is contained in:
@ -101,14 +101,12 @@ template <typename T>
|
|||||||
using variant_index_sequence =
|
using variant_index_sequence =
|
||||||
std::make_index_sequence<std::variant_size<T>::value>;
|
std::make_index_sequence<std::variant_size<T>::value>;
|
||||||
|
|
||||||
// variant_size and variant_alternative check.
|
template <typename>
|
||||||
template <typename T, typename U = void>
|
|
||||||
struct is_variant_like_ : std::false_type {};
|
struct is_variant_like_ : std::false_type {};
|
||||||
template <typename T>
|
template <typename... Types>
|
||||||
struct is_variant_like_<T, std::void_t<decltype(std::variant_size<T>::value)>>
|
struct is_variant_like_<std::variant<Types...>> : std::true_type {};
|
||||||
: std::true_type {};
|
|
||||||
|
|
||||||
// formattable element check
|
// formattable element check.
|
||||||
template <typename T, typename C> class is_variant_formattable_ {
|
template <typename T, typename C> class is_variant_formattable_ {
|
||||||
template <std::size_t... I>
|
template <std::size_t... I>
|
||||||
static std::conjunction<
|
static std::conjunction<
|
||||||
|
@ -75,6 +75,9 @@ TEST(std_test, variant) {
|
|||||||
|
|
||||||
EXPECT_EQ(fmt::format("{}", v4), "variant(monostate)");
|
EXPECT_EQ(fmt::format("{}", v4), "variant(monostate)");
|
||||||
EXPECT_EQ(fmt::format("{}", v5), "variant(\"yes, this is variant\")");
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user