From c7a0c83ed44ec793285ebab58a86b232d10b5082 Mon Sep 17 00:00:00 2001 From: neargye Date: Sat, 9 Oct 2021 02:40:44 +0300 Subject: [PATCH] constexpr_for not work on vs2017 --- test/test.cpp | 8 ++++++++ test/test_flags.cpp | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/test/test.cpp b/test/test.cpp index dd8b54d..c595249 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -974,6 +974,12 @@ TEST_CASE("cmp_less") { } } +#if defined(__clang__) && __clang_major__ >= 5 || defined(__GNUC__) && __GNUC__ >= 9 || defined(_MSC_VER) && _MSC_VER >= 1920 +# define MAGIC_ENUM_SUPPORTED_CONSTEXPR_FOR 1 +#endif + +#if defined(MAGIC_ENUM_SUPPORTED_CONSTEXPR_FOR) + // from https://artificial-mind.net/blog/2020/10/31/constexpr-for template constexpr void constexpr_for(F&& f) { @@ -995,3 +1001,5 @@ TEST_CASE("constexpr_for") { [[maybe_unused]] Foo()> bar{}; }); } + +#endif diff --git a/test/test_flags.cpp b/test/test_flags.cpp index f6be44c..5efcb9b 100644 --- a/test/test_flags.cpp +++ b/test/test_flags.cpp @@ -691,6 +691,12 @@ TEST_CASE("bitwise_operators") { } } +#if defined(__clang__) && __clang_major__ >= 5 || defined(__GNUC__) && __GNUC__ >= 9 || defined(_MSC_VER) && _MSC_VER >= 1920 +# define MAGIC_ENUM_SUPPORTED_CONSTEXPR_FOR 1 +#endif + +#if defined(MAGIC_ENUM_SUPPORTED_CONSTEXPR_FOR) + // from https://artificial-mind.net/blog/2020/10/31/constexpr-for template constexpr void constexpr_for(F&& f) { @@ -707,4 +713,6 @@ TEST_CASE("constexpr_for") { constexpr_for<0, magic_enum::enum_count(), 1>([](auto i) { [[maybe_unused]] Foo()> bar{}; }); -} \ No newline at end of file +} + +#endif