diff --git a/test/test.cpp b/test/test.cpp index a464f05..dd8b54d 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -973,3 +973,25 @@ TEST_CASE("cmp_less") { REQUIRE(cmp_less(-1, false)); } } + +// from https://artificial-mind.net/blog/2020/10/31/constexpr-for +template +constexpr void constexpr_for(F&& f) { + if constexpr (Start < End) { + f(std::integral_constant()); + constexpr_for(f); + } +} + +template +struct Foo {}; + +TEST_CASE("constexpr_for") { + constexpr_for<0, magic_enum::enum_count(), 1>([](auto i) { + [[maybe_unused]] Foo()> bar{}; + }); + + constexpr_for<0, magic_enum::enum_count(), 1>([](auto i) { + [[maybe_unused]] Foo()> bar{}; + }); +} diff --git a/test/test_flags.cpp b/test/test_flags.cpp index a3f8ea8..f6be44c 100644 --- a/test/test_flags.cpp +++ b/test/test_flags.cpp @@ -690,3 +690,21 @@ TEST_CASE("bitwise_operators") { #endif } } + +// from https://artificial-mind.net/blog/2020/10/31/constexpr-for +template +constexpr void constexpr_for(F&& f) { + if constexpr (Start < End) { + f(std::integral_constant()); + constexpr_for(f); + } +} + +template +struct Foo {}; + +TEST_CASE("constexpr_for") { + constexpr_for<0, magic_enum::enum_count(), 1>([](auto i) { + [[maybe_unused]] Foo()> bar{}; + }); +} \ No newline at end of file