diff --git a/include/boost/math/policies/policy.hpp b/include/boost/math/policies/policy.hpp index c7dc8ef5c..c43b35fa4 100644 --- a/include/boost/math/policies/policy.hpp +++ b/include/boost/math/policies/policy.hpp @@ -409,14 +409,26 @@ private: using arg_list = mp_list; static constexpr std::size_t arg_list_size = mp_size::value; + template + struct pick_arg + { + using type = A; + }; + + template + struct pick_arg + { + using type = mp_at; + }; + public: using domain_error_type = typename detail::find_arg, domain_error<> >::type; // Now try to calculate the same domain error type using MP11 using domain_error_fn = mp_quote_trait; using domain_error_index = mp_find_if_q; - static constexpr std::size_t domain_error_index_adjusted = domain_error_index::value >= arg_list_size ? domain_error_index::value - 1 : domain_error_index::value; - using new_domain_error_type = typename std::conditional, domain_error<>>::type; + static constexpr bool end = (domain_error_index::value >= arg_list_size); + using new_domain_error_type = typename pick_arg, domain_error_index, end>::type; static_assert(std::is_same::value, "MP11 is incorrect"); diff --git a/test/test_policy.cpp b/test/test_policy.cpp index 2bcd1ba86..5f00788a0 100644 --- a/test/test_policy.cpp +++ b/test/test_policy.cpp @@ -49,7 +49,7 @@ BOOST_AUTO_TEST_CASE( test_main ) BOOST_CHECK((std::is_same >::promote_float_type, policy<>::promote_float_type>::value)); BOOST_CHECK((std::is_same >::promote_double_type, policy<>::promote_double_type>::value)); BOOST_CHECK((std::is_same >::discrete_quantile_type, policy<>::discrete_quantile_type>::value)); - /* + BOOST_CHECK((std::is_same >::domain_error_type, policy<>::domain_error_type >::value)); BOOST_CHECK((std::is_same >::pole_error_type, pole_error >::value)); BOOST_CHECK((std::is_same >::overflow_error_type, overflow_error >::value)); @@ -169,7 +169,6 @@ BOOST_AUTO_TEST_CASE( test_main ) BOOST_CHECK((std::is_same >::promote_float_type, policy<>::promote_float_type>::value)); BOOST_CHECK((std::is_same >::promote_double_type, policy<>::promote_double_type>::value)); BOOST_CHECK((std::is_same >::discrete_quantile_type, discrete_quantile >::value)); - */ } // BOOST_AUTO_TEST_CASE( test_main )