mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-10 23:44:29 +00:00
constexpr_for not work on vs2017
This commit is contained in:
parent
018673a0a4
commit
c7a0c83ed4
2 changed files with 17 additions and 1 deletions
|
|
@ -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
|
// from https://artificial-mind.net/blog/2020/10/31/constexpr-for
|
||||||
template <auto Start, auto End, auto Inc, class F>
|
template <auto Start, auto End, auto Inc, class F>
|
||||||
constexpr void constexpr_for(F&& f) {
|
constexpr void constexpr_for(F&& f) {
|
||||||
|
|
@ -995,3 +1001,5 @@ TEST_CASE("constexpr_for") {
|
||||||
[[maybe_unused]] Foo<Numbers, magic_enum::enum_value<Numbers, i>()> bar{};
|
[[maybe_unused]] Foo<Numbers, magic_enum::enum_value<Numbers, i>()> bar{};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -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
|
// from https://artificial-mind.net/blog/2020/10/31/constexpr-for
|
||||||
template <auto Start, auto End, auto Inc, class F>
|
template <auto Start, auto End, auto Inc, class F>
|
||||||
constexpr void constexpr_for(F&& f) {
|
constexpr void constexpr_for(F&& f) {
|
||||||
|
|
@ -707,4 +713,6 @@ TEST_CASE("constexpr_for") {
|
||||||
constexpr_for<0, magic_enum::enum_count<Color>(), 1>([](auto i) {
|
constexpr_for<0, magic_enum::enum_count<Color>(), 1>([](auto i) {
|
||||||
[[maybe_unused]] Foo<Color, magic_enum::enum_value<Color, i>()> bar{};
|
[[maybe_unused]] Foo<Color, magic_enum::enum_value<Color, i>()> bar{};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue