diff --git a/Eigen/src/Core/CwiseUnaryView.h b/Eigen/src/Core/CwiseUnaryView.h index fdf68f0fc..f1653c87a 100644 --- a/Eigen/src/Core/CwiseUnaryView.h +++ b/Eigen/src/Core/CwiseUnaryView.h @@ -18,9 +18,11 @@ namespace Eigen { namespace internal { template struct traits > : traits { - typedef typename std::result_of::Scalar&)>::type ScalarRef; + typedef typename result_of::Scalar&)>::type1 ScalarRef; static_assert(std::is_reference::value, "Views must return a reference type."); - typedef remove_all_t Scalar; + typedef remove_all_t MutableScalar; + // Ensure const matrices stay const. + typedef std::conditional_t::value, const MutableScalar, MutableScalar> Scalar; typedef typename MatrixType::Nested MatrixTypeNested; typedef remove_all_t MatrixTypeNested_; enum {