#include #include #include "test.hpp" // TODO: Test default construction, and static initialization struct increment_constant { template constexpr std::integral_constant operator()(T) const noexcept { return std::integral_constant(); } }; struct increment { template constexpr T operator()(T x) const noexcept { return x + 1; } }; struct not_6_constant { template constexpr std::integral_constant operator()(T) const noexcept { return std::integral_constant(); } }; struct not_6 { template constexpr bool operator()(T x) const noexcept { return x != 6; } }; struct not_limit { template constexpr bool operator()(T x) const { return x != (FIT_RECURSIVE_CONSTEXPR_DEPTH+4); } }; #if FIT_HAS_NOEXCEPT_DEDUCTION FIT_TEST_CASE() { static_assert(noexcept(fit::repeat_while(not_6())(increment())(1)), "noexcept repeat_while"); static_assert(noexcept(fit::repeat_while(not_6_constant())(increment_constant())(std::integral_constant())), "noexcept repeat_while"); } #endif FIT_TEST_CASE() { static_assert ( std::is_same< std::integral_constant, decltype(fit::repeat_while(not_6_constant())(increment_constant())(std::integral_constant())) >::value, "Error" ); std::integral_constant x = fit::repeat_while(not_6_constant())(increment_constant())(std::integral_constant()); fit::test::unused(x); } FIT_TEST_CASE() { FIT_STATIC_TEST_CHECK(fit::repeat_while(not_6())(increment())(1) == 6); FIT_TEST_CHECK(fit::repeat_while(not_6())(increment())(1) == 6); FIT_TEST_CHECK(fit::reveal(fit::repeat_while(not_6())(increment()))(1) == 6); } FIT_TEST_CASE() { FIT_TEST_CHECK(fit::repeat_while(not_limit())(increment())(1) == FIT_RECURSIVE_CONSTEXPR_DEPTH+4); #if FIT_HAS_RELAXED_CONSTEXPR FIT_STATIC_TEST_CHECK(fit::repeat_while(not_limit())(increment())(1) == FIT_RECURSIVE_CONSTEXPR_DEPTH+4); #endif }