diff --git a/test/common_helper/test.hpp b/test/common_helper/test.hpp index dac4f70..45fc833 100644 --- a/test/common_helper/test.hpp +++ b/test/common_helper/test.hpp @@ -155,7 +155,7 @@ struct ret_val { struct empty_param {}; -struct test_params { +struct test_common_params { template constexpr static auto value = empty_param{}; }; @@ -169,6 +169,21 @@ struct test_context_params { constexpr static auto value = empty_param{}; }; +template +struct test_params { + constexpr static auto get() { + if constexpr (requires { typename Ctx::type; }) { + if constexpr (requires { { Ctx::nr } -> std::convertible_to; }) { + return test_context_params::template value; + } else { + return test_context_params::template value; + } + } else { + return test_common_params::template value; + } + } +}; + #define CONTEXT_PARAM(type, name, ...) template<> template<> constexpr type test_context_params<__VA_ARGS__>::value< #name > #define CONTEXT_PARAM_ARR(type, name, ...) template<> template<> constexpr type test_context_params<__VA_ARGS__>::value< #name >[] @@ -396,7 +411,9 @@ template constexpr auto _repeat_for_types_n(auto f) { std::array rets = { [&](std::index_sequence) constexpr { - return std::array { f.template operator()>()... }; + return std::array { + (f.template operator()>())... + }; }.template operator()(std::make_index_sequence())... }; // Clion does not accept this as a constant expression diff --git a/test/const_vector/const_vector_constructor.test.cpp b/test/const_vector/const_vector_constructor.test.cpp index afa988e..9889dae 100644 --- a/test/const_vector/const_vector_constructor.test.cpp +++ b/test/const_vector/const_vector_constructor.test.cpp @@ -1188,17 +1188,17 @@ constexpr test_suite tests = define_tests("Tests") }, EvalFlag::RUNTIME_CONSTEVAL) ("const_vector::assign(std::initializer_list values)", []() constexpr { - REPEAT_FOR_TYPES_N(([]() constexpr { + REPEAT_FOR_TYPES_N(([]() constexpr { - cc::const_vector).size()> v1; - cc::const_vector).size() - 1> v2; + cc::const_vector::get()).size()> v1; + cc::const_vector::get()).size() - 1> v2; - v1.assign(params::template value<"ilist">); + v1.assign(test_params<"ilist", Ctx>::get()); - ASSERT_TYPE_NUM_VEC_ARR_EQ(v1, params::template value<"ilist">, T, N); - ASSERT_TYPE_NUM(v1.size() == params::template value<"ilist">.size(), T, N); + ASSERT_TYPE_NUM_VEC_ARR_EQ(v1, (test_params<"ilist", Ctx>::get()), T, N); + ASSERT_TYPE_NUM((v1.size() == test_params<"ilist", Ctx>::get().size()), T, N); - ASSERT_TYPE_NUM_THROWS(v2.assign(params::template value<"ilist">), std::invalid_argument, T, N); + ASSERT_TYPE_NUM_THROWS(v2.assign(test_params<"ilist", Ctx>::get()), std::invalid_argument, T, N); return TEST_PASS(); }), 2, int, char, const char *, TestObj);