From b37551f62aa89d93bab82d171c1caeb7baf54885 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 16 Aug 2010 11:13:02 +0200 Subject: [PATCH] further improve compilation error message for array+=matrix --- Eigen/src/Core/ArrayBase.h | 6 ++++-- Eigen/src/Core/MatrixBase.h | 6 ++++-- Eigen/src/Core/util/StaticAssert.h | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Eigen/src/Core/ArrayBase.h b/Eigen/src/Core/ArrayBase.h index c53ea0a4f..36bf71dde 100644 --- a/Eigen/src/Core/ArrayBase.h +++ b/Eigen/src/Core/ArrayBase.h @@ -169,9 +169,11 @@ template class ArrayBase template explicit ArrayBase(const ArrayBase&); protected: // mixing arrays and matrices is not legal - template Derived& operator+=(const MatrixBase& mat); + template Derived& operator+=(const MatrixBase& mat) + {EIGEN_STATIC_ASSERT(sizeof(typename OtherDerived::Scalar)==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES);} // mixing arrays and matrices is not legal - template Derived& operator-=(const MatrixBase& mat); + template Derived& operator-=(const MatrixBase& mat) + {EIGEN_STATIC_ASSERT(sizeof(typename OtherDerived::Scalar)==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES);} }; /** replaces \c *this by \c *this - \a other. diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 1b0784c2b..a05614d1b 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -429,9 +429,11 @@ template class MatrixBase template explicit MatrixBase(const MatrixBase&); protected: // mixing arrays and matrices is not legal - template Derived& operator+=(const ArrayBase& array); + template Derived& operator+=(const ArrayBase& array) + {EIGEN_STATIC_ASSERT(sizeof(typename OtherDerived::Scalar)==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES);} // mixing arrays and matrices is not legal - template Derived& operator-=(const ArrayBase& array); + template Derived& operator-=(const ArrayBase& array) + {EIGEN_STATIC_ASSERT(sizeof(typename OtherDerived::Scalar)==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES);} }; #endif // EIGEN_MATRIXBASE_H diff --git a/Eigen/src/Core/util/StaticAssert.h b/Eigen/src/Core/util/StaticAssert.h index f1d9d7b3d..d285f79b1 100644 --- a/Eigen/src/Core/util/StaticAssert.h +++ b/Eigen/src/Core/util/StaticAssert.h @@ -87,7 +87,8 @@ INVALID_STORAGE_ORDER_FOR_THIS_VECTOR_EXPRESSION, THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD, PACKET_ACCESS_REQUIRES_TO_HAVE_INNER_STRIDE_FIXED_TO_1, - THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS + THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS, + YOU_CANNOT_MIX_ARRAYS_AND_MATRICES }; };