From 4dda45ce21bebdba57a570dec6b365d9727916fd Mon Sep 17 00:00:00 2001 From: Nikita Kniazev Date: Sun, 31 Mar 2019 23:41:03 +0300 Subject: [PATCH] Fixed recursion in extract_value_type Some types (like Boost.Multiprecision ones) define `value_type` to the same type as they are, what causes `extract_value_type` instantiation to fail with an incomplete type instantiation error. --- .../algebra/detail/extract_value_type.hpp | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/include/boost/numeric/odeint/algebra/detail/extract_value_type.hpp b/include/boost/numeric/odeint/algebra/detail/extract_value_type.hpp index c5246bb6f..8d4340dfa 100644 --- a/include/boost/numeric/odeint/algebra/detail/extract_value_type.hpp +++ b/include/boost/numeric/odeint/algebra/detail/extract_value_type.hpp @@ -18,7 +18,10 @@ #define BOOST_NUMERIC_ODEINT_ALGEBRA_DETAIL_EXTRACT_VALUE_TYPE_HPP_INCLUDED #include +#include +#include #include +#include BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type) @@ -28,24 +31,20 @@ namespace odeint { namespace detail { template< typename S , typename Enabler = void > -struct extract_value_type {}; - -// as long as value_types are defined we go down the value_type chain -// e.g. returning S::value_type::value_type::value_type - -template< typename S > -struct extract_value_type >::type > +struct extract_value_type { - // no value_type defined, return S typedef S type; }; +// as long as value_types are defined we go down the value_type chain +// e.g. returning S::value_type::value_type::value_type + template< typename S > struct extract_value_type< S , typename boost::enable_if< has_value_type >::type > -{ - // go down the value_type - typedef typename extract_value_type< typename S::value_type >::type type; -}; + : mpl::if_< is_same< S, typename S::value_type > , + mpl::identity< S > , // cut the recursion if S and S::value_type are the same + extract_value_type< typename S::value_type > >::type +{}; } } } }