diff --git a/Eigen/src/Core/ArithmeticSequence.h b/Eigen/src/Core/ArithmeticSequence.h index 056ace1f2..2ad4c0906 100644 --- a/Eigen/src/Core/ArithmeticSequence.h +++ b/Eigen/src/Core/ArithmeticSequence.h @@ -44,8 +44,8 @@ public: ArithmeticSequence(FirstType first, SizeType size, IncrType incr) : m_first(first), m_size(size), m_incr(incr) {} enum { - SizeAtCompileTime = internal::get_compile_time::value, - IncrAtCompileTime = internal::get_compile_time::value + SizeAtCompileTime = internal::get_fixed_value::value, + IncrAtCompileTime = internal::get_fixed_value::value }; /** \returns the size, i.e., number of elements, of the sequence */ @@ -69,25 +69,9 @@ protected: namespace internal { -// Cleanup return types: - -// By default, no change: -template struct cleanup_seq_type { typedef T type; }; - -// Convert short, int, unsigned int, etc. to Eigen::Index -template struct cleanup_seq_type::value>::type> { typedef Index type; }; - -// In c++98/c++11, fix is a pointer to function that we better cleanup to a true fix_t: -template struct cleanup_seq_type (*)(), DynamicKey> { typedef fix_t type; }; - -// If variable_or_fixed does not match DynamicKey, then we turn it to a pure compile-time value: -template struct cleanup_seq_type, DynamicKey> { typedef fix_t type; }; -// If variable_or_fixed matches DynamicKey, then we turn it to a pure runtime-value (aka Index): -template struct cleanup_seq_type, DynamicKey> { typedef Index type; }; - // Helper to cleanup the type of the increment: template struct cleanup_seq_incr { - typedef typename cleanup_seq_type::type type; + typedef typename cleanup_index_type::type type; }; } @@ -96,18 +80,18 @@ template struct cleanup_seq_incr { * * \sa seqN(FirstType,SizeType), seq(FirstType,LastType,IncrType) */ template -ArithmeticSequence::type,typename internal::cleanup_seq_type::type,typename internal::cleanup_seq_incr::type > +ArithmeticSequence::type,typename internal::cleanup_index_type::type,typename internal::cleanup_seq_incr::type > seqN(FirstType first, SizeType size, IncrType incr) { - return ArithmeticSequence::type,typename internal::cleanup_seq_type::type,typename internal::cleanup_seq_incr::type>(first,size,incr); + return ArithmeticSequence::type,typename internal::cleanup_index_type::type,typename internal::cleanup_seq_incr::type>(first,size,incr); } /** \returns an ArithmeticSequence starting at \a first, of length \a size, and unit increment * * \sa seqN(FirstType,SizeType,IncrType), seq(FirstType,LastType) */ template -ArithmeticSequence::type,typename internal::cleanup_seq_type::type > +ArithmeticSequence::type,typename internal::cleanup_index_type::type > seqN(FirstType first, SizeType size) { - return ArithmeticSequence::type,typename internal::cleanup_seq_type::type>(first,size); + return ArithmeticSequence::type,typename internal::cleanup_index_type::type>(first,size); } #ifdef EIGEN_PARSED_BY_DOXYGEN @@ -156,7 +140,7 @@ auto seq(FirstType f, LastType l, IncrType incr) #else template typename internal::enable_if::value || Symbolic::is_symbolic::value), - ArithmeticSequence::type,Index> >::type + ArithmeticSequence::type,Index> >::type seq(FirstType f, LastType l) { return seqN(f,(l-f+1)); @@ -173,7 +157,7 @@ seq(const Symbolic::BaseExpr &f, LastType l) template typename internal::enable_if::value, - ArithmeticSequence::type, + ArithmeticSequence::type, Symbolic::AddExpr,Symbolic::ValueExpr> > >::type seq(FirstType f, const Symbolic::BaseExpr &l) { @@ -191,7 +175,7 @@ seq(const Symbolic::BaseExpr &f, const Symbolic::BaseExpr typename internal::enable_if::value || Symbolic::is_symbolic::value), - ArithmeticSequence::type,Index,typename internal::cleanup_seq_incr::type> >::type + ArithmeticSequence::type,Index,typename internal::cleanup_seq_incr::type> >::type seq(FirstType f, LastType l, IncrType incr) { typedef typename internal::cleanup_seq_incr::type CleanedIncrType; @@ -214,7 +198,7 @@ seq(const Symbolic::BaseExpr &f, LastType l, IncrType incr) template typename internal::enable_if::value, - ArithmeticSequence::type, + ArithmeticSequence::type, Symbolic::QuotientExpr, Symbolic::ValueExpr>, Symbolic::ValueExpr>, @@ -263,7 +247,7 @@ makeIndexedViewCompatible(const ArithmeticSequence& template struct get_compile_time_incr > { - enum { value = get_compile_time::value }; + enum { value = get_fixed_value::value }; }; } // end namespace internal @@ -323,7 +307,7 @@ public: enum { SizeAtCompileTime = -1, - IncrAtCompileTime = internal::get_compile_time::value + IncrAtCompileTime = internal::get_fixed_value::value }; Index size() const { return (m_last-m_first+m_incr)/m_incr; } @@ -340,19 +324,19 @@ protected: }; template -ArithmeticSequenceProxyWithBounds::type,typename internal::cleanup_seq_type::type > +ArithmeticSequenceProxyWithBounds::type,typename internal::cleanup_index_type::type > seq(FirstType f, LastType l) { - return ArithmeticSequenceProxyWithBounds::type,typename internal::cleanup_seq_type::type>(f,l); + return ArithmeticSequenceProxyWithBounds::type,typename internal::cleanup_index_type::type>(f,l); } template -ArithmeticSequenceProxyWithBounds< typename internal::cleanup_seq_type::type, - typename internal::cleanup_seq_type::type, +ArithmeticSequenceProxyWithBounds< typename internal::cleanup_index_type::type, + typename internal::cleanup_index_type::type, typename internal::cleanup_seq_incr::type > seq(FirstType f, LastType l, IncrType s) { - return ArithmeticSequenceProxyWithBounds::type, - typename internal::cleanup_seq_type::type, + return ArithmeticSequenceProxyWithBounds::type, + typename internal::cleanup_index_type::type, typename internal::cleanup_seq_incr::type> (f,l,typename internal::cleanup_seq_incr::type(s)); } @@ -363,7 +347,7 @@ namespace internal { template struct get_compile_time_incr > { - enum { value = get_compile_time::value }; + enum { value = get_fixed_value::value }; }; // Convert a symbolic range into a usable one (i.e., remove last/end "keywords") diff --git a/Eigen/src/Core/util/IndexedViewHelper.h b/Eigen/src/Core/util/IndexedViewHelper.h index 09637a157..b4f7c0dd7 100644 --- a/Eigen/src/Core/util/IndexedViewHelper.h +++ b/Eigen/src/Core/util/IndexedViewHelper.h @@ -159,8 +159,8 @@ struct IndexedViewCompatibleType { }; template -inline AllRange::value> makeIndexedViewCompatible(all_t , XprSizeType size, SpecializedType) { - return AllRange::value>(size); +inline AllRange::value> makeIndexedViewCompatible(all_t , XprSizeType size, SpecializedType) { + return AllRange::value>(size); } template struct get_compile_time_incr > { diff --git a/Eigen/src/Core/util/IntegralConstant.h b/Eigen/src/Core/util/IntegralConstant.h index 003856b20..2402baeec 100644 --- a/Eigen/src/Core/util/IntegralConstant.h +++ b/Eigen/src/Core/util/IntegralConstant.h @@ -46,30 +46,51 @@ protected: int m_value; }; -template struct get_compile_time { +template struct get_fixed_value { static const int value = Default; }; -template struct get_compile_time,Default> { +template struct get_fixed_value,Default> { static const int value = N; }; -template struct get_compile_time (*)(),Default> { +#if !EIGEN_HAS_CXX14 +template struct get_fixed_value (*)(),Default> { static const int value = N; }; +#endif -template struct get_compile_time,Default> { +template struct get_fixed_value,Default> { static const int value = N ; }; template -struct get_compile_time,Default> { +struct get_fixed_value,Default> { static const int value = N; }; +template Index get_runtime_value(const T &x) { return x; } +#if !EIGEN_HAS_CXX14 +template Index get_runtime_value(fix_t (*)()) { return N; } +#endif -template struct is_compile_time { enum { value = false }; }; -template struct is_compile_time > { enum { value = true }; }; +// Cleanup integer/fix_t/variable_or_fixed/etc types: + +// By default, no cleanup: +template struct cleanup_index_type { typedef T type; }; + +// Convert any integral type (e.g., short, int, unsigned int, etc.) to Eigen::Index +template struct cleanup_index_type::value>::type> { typedef Index type; }; + +#if !EIGEN_HAS_CXX14 +// In c++98/c++11, fix is a pointer to function that we better cleanup to a true fix_t: +template struct cleanup_index_type (*)(), DynamicKey> { typedef fix_t type; }; +#endif + +// If variable_or_fixed does not match DynamicKey, then we turn it to a pure compile-time value: +template struct cleanup_index_type, DynamicKey> { typedef fix_t type; }; +// If variable_or_fixed matches DynamicKey, then we turn it to a pure runtime-value (aka Index): +template struct cleanup_index_type, DynamicKey> { typedef Index type; }; } // end namespace internal