Generalize static assertions on matching sizes to avoid the need for SizeAtCompileTime

This commit is contained in:
Gael Guennebaud 2014-06-25 17:22:12 +02:00
parent 199ac3f2e7
commit 3b19b466a7
2 changed files with 6 additions and 1 deletions

View File

@ -159,7 +159,7 @@
#define EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0,TYPE1) \ #define EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0,TYPE1) \
( \ ( \
(int(TYPE0::SizeAtCompileTime)==0 && int(TYPE1::SizeAtCompileTime)==0) \ (int(internal::size_of_xpr_at_compile_time<TYPE0>::ret)==0 && int(internal::size_of_xpr_at_compile_time<TYPE1>::ret)==0) \
|| (\ || (\
(int(TYPE0::RowsAtCompileTime)==Eigen::Dynamic \ (int(TYPE0::RowsAtCompileTime)==Eigen::Dynamic \
|| int(TYPE1::RowsAtCompileTime)==Eigen::Dynamic \ || int(TYPE1::RowsAtCompileTime)==Eigen::Dynamic \

View File

@ -216,6 +216,11 @@ template<int _Rows, int _Cols> struct size_at_compile_time
enum { ret = (_Rows==Dynamic || _Cols==Dynamic) ? Dynamic : _Rows * _Cols }; enum { ret = (_Rows==Dynamic || _Cols==Dynamic) ? Dynamic : _Rows * _Cols };
}; };
template<typename XprType> struct size_of_xpr_at_compile_time
{
enum { ret = size_at_compile_time<traits<XprType>::RowsAtCompileTime,traits<XprType>::ColsAtCompileTime>::ret };
};
/* plain_matrix_type : the difference from eval is that plain_matrix_type is always a plain matrix type, /* plain_matrix_type : the difference from eval is that plain_matrix_type is always a plain matrix type,
* whereas eval is a const reference in the case of a matrix * whereas eval is a const reference in the case of a matrix
*/ */