diff --git a/Eigen/src/Core/CwiseUnaryOp.h b/Eigen/src/Core/CwiseUnaryOp.h index 076d568e0..5915dad54 100644 --- a/Eigen/src/Core/CwiseUnaryOp.h +++ b/Eigen/src/Core/CwiseUnaryOp.h @@ -188,7 +188,11 @@ MatrixBase::imag() const { return derived(); } */ template template -EIGEN_STRONG_INLINE const CwiseUnaryOp::Scalar, NewType>, Derived> +EIGEN_STRONG_INLINE +typename ei_cast_return_type< + const Derived&, + const CwiseUnaryOp::Scalar, NewType>, Derived> + >::type MatrixBase::cast() const { return derived(); diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index a4e4e15d7..7eb7c1eff 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -504,8 +504,12 @@ template class MatrixBase template - const CwiseUnaryOp::Scalar, NewType>, Derived> cast() const; - + typename ei_cast_return_type< + const Derived&, + const CwiseUnaryOp::Scalar, NewType>, Derived> + >::type + cast() const; + /** \returns the matrix or vector obtained by evaluating this expression. * * Notice that in the case of a plain matrix or vector (not an expression) this function just returns