aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-09-30 15:47:11 -0400
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-09-30 15:47:11 -0400
commit3a315fdc9ad7dddc746af537ecafce9d25c52fbc (patch)
treed1b0ccb4f9ac92ac22e861d547377788486e80e2
parentd7a2a37a4c1728dbddbfae9d577e2e49f5edda65 (diff)
make Replicate ctor require the exact expected type
-rw-r--r--Eigen/src/Array/Replicate.h13
-rw-r--r--Eigen/src/Core/util/StaticAssert.h3
2 files changed, 12 insertions, 4 deletions
diff --git a/Eigen/src/Array/Replicate.h b/Eigen/src/Array/Replicate.h
index 02f9c0601..b20bcd49a 100644
--- a/Eigen/src/Array/Replicate.h
+++ b/Eigen/src/Array/Replicate.h
@@ -69,15 +69,22 @@ template<typename MatrixType,int RowFactor,int ColFactor> class Replicate
EIGEN_GENERIC_PUBLIC_INTERFACE(Replicate)
- inline Replicate(const MatrixType& matrix)
+ template<typename OriginalMatrixType>
+ inline Replicate(const OriginalMatrixType& matrix)
: m_matrix(matrix), m_rowFactor(RowFactor), m_colFactor(ColFactor)
{
+ EIGEN_STATIC_ASSERT((ei_is_same_type<MatrixType,OriginalMatrixType>::ret),
+ THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)
ei_assert(RowFactor!=Dynamic && ColFactor!=Dynamic);
}
- inline Replicate(const MatrixType& matrix, int rowFactor, int colFactor)
+ template<typename OriginalMatrixType>
+ inline Replicate(const OriginalMatrixType& matrix, int rowFactor, int colFactor)
: m_matrix(matrix), m_rowFactor(rowFactor), m_colFactor(colFactor)
- {}
+ {
+ EIGEN_STATIC_ASSERT((ei_is_same_type<MatrixType,OriginalMatrixType>::ret),
+ THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)
+ }
inline int rows() const { return m_matrix.rows() * m_rowFactor.value(); }
inline int cols() const { return m_matrix.cols() * m_colFactor.value(); }
diff --git a/Eigen/src/Core/util/StaticAssert.h b/Eigen/src/Core/util/StaticAssert.h
index 7116e4d0f..883f2d95e 100644
--- a/Eigen/src/Core/util/StaticAssert.h
+++ b/Eigen/src/Core/util/StaticAssert.h
@@ -77,7 +77,8 @@
THIS_METHOD_IS_ONLY_FOR_ROW_MAJOR_MATRICES,
INVALID_MATRIX_TEMPLATE_PARAMETERS,
BOTH_MATRICES_MUST_HAVE_THE_SAME_STORAGE_ORDER,
- THIS_METHOD_IS_ONLY_FOR_DIAGONAL_MATRIX
+ THIS_METHOD_IS_ONLY_FOR_DIAGONAL_MATRIX,
+ THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE
};
};