mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
centralize those static asserts more upstream, reduces duplication and ensures they can't be bypassed (e.g.
until now it was possible to bypass the static assert on sizes)
This commit is contained in:
@@ -401,6 +401,8 @@ EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>
|
|||||||
::lazyAssign(const MatrixBase<OtherDerived>& other)
|
::lazyAssign(const MatrixBase<OtherDerived>& other)
|
||||||
{
|
{
|
||||||
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived)
|
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived)
|
||||||
|
EIGEN_STATIC_ASSERT((ei_is_same_type<typename Derived::Scalar, typename OtherDerived::Scalar>::ret),
|
||||||
|
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
|
||||||
ei_assert(rows() == other.rows() && cols() == other.cols());
|
ei_assert(rows() == other.rows() && cols() == other.cols());
|
||||||
ei_assign_impl<Derived, OtherDerived>::run(derived(),other.derived());
|
ei_assign_impl<Derived, OtherDerived>::run(derived(),other.derived());
|
||||||
return derived();
|
return derived();
|
||||||
@@ -437,8 +439,6 @@ template<typename OtherDerived>
|
|||||||
EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>
|
EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>
|
||||||
::operator=(const MatrixBase<OtherDerived>& other)
|
::operator=(const MatrixBase<OtherDerived>& other)
|
||||||
{
|
{
|
||||||
EIGEN_STATIC_ASSERT((ei_is_same_type<Scalar, typename OtherDerived::Scalar>::ret),
|
|
||||||
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
|
|
||||||
return ei_assign_selector<Derived,OtherDerived>::run(derived(), other.derived());
|
return ei_assign_selector<Derived,OtherDerived>::run(derived(), other.derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -503,8 +503,6 @@ class Matrix
|
|||||||
EIGEN_STRONG_INLINE Matrix& _set_noalias(const MatrixBase<OtherDerived>& other)
|
EIGEN_STRONG_INLINE Matrix& _set_noalias(const MatrixBase<OtherDerived>& other)
|
||||||
{
|
{
|
||||||
_resize_to_match(other);
|
_resize_to_match(other);
|
||||||
EIGEN_STATIC_ASSERT((ei_is_same_type<Scalar, typename OtherDerived::Scalar>::ret),
|
|
||||||
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
|
|
||||||
// the 'false' below means to enforce lazy evaluation. We don't use lazyAssign() because
|
// the 'false' below means to enforce lazy evaluation. We don't use lazyAssign() because
|
||||||
// it wouldn't allow to copy a row-vector into a column-vector.
|
// it wouldn't allow to copy a row-vector into a column-vector.
|
||||||
return ei_assign_selector<Matrix,OtherDerived,false>::run(*this, other.derived());
|
return ei_assign_selector<Matrix,OtherDerived,false>::run(*this, other.derived());
|
||||||
|
|||||||
Reference in New Issue
Block a user