Currently expressions tend to store their nested expressions as const, for example at src/Core/Block.h:344, in class Block: const typename XprType::Nested m_xpr; Consequently, mutators have to call const_cast_derived() on the nested expression. This seems stupid and seems like something we want to fix for Eigen 3.1. By storing nested expressions with their own native constness, we could also drop those const_cast's.
Here is a list of all remaining occurrences: Core\DiagonalProduct.h(110): const typename MatrixType::Nested m_matrix; Core\DiagonalProduct.h(111): const typename DiagonalType::Nested m_diagonal; Core\IO.h(118): const typename ExpressionType::Nested m_matrix; Core\PermutationMatrix.h(514): const typename IndicesType::Nested m_indices; Core\PermutationMatrix.h(611): const typename MatrixType::Nested m_matrix; Core\Replicate.h(127): const typename MatrixType::Nested m_matrix; Core\Reverse.h(187): const typename MatrixType::Nested m_matrix; Core\Select.h(105): const typename ConditionMatrixType::Nested m_condition; Core\Select.h(106): const typename ThenMatrixType::Nested m_then; Core\Select.h(107): const typename ElseMatrixType::Nested m_else; Core\SolveTriangular.h(265): const typename Rhs::Nested m_rhs; Core\Transpositions.h(337): const typename IndicesType::Nested m_indices; Core\Transpositions.h(407): const typename MatrixType::Nested m_matrix; Eigen2Support\Minor.h(98): const typename MatrixType::Nested m_matrix; Eigenvalues\Tridiagonalization.h(563): const typename MatrixType::Nested m_matrix; Geometry\Homogeneous.h(124): const typename MatrixType::Nested m_matrix; Geometry\Homogeneous.h(270): const typename LhsMatrixType::Nested m_lhs; Geometry\Homogeneous.h(271): const typename MatrixType::Nested m_rhs; Geometry\Homogeneous.h(309): const typename MatrixType::Nested m_lhs; Geometry\Homogeneous.h(310): const typename Rhs::Nested m_rhs; misc\Solve.h(69): const typename Rhs::Nested m_rhs; Sparse\SparseBlock.h(99): const typename MatrixType::Nested m_matrix; Sparse\SparseBlock.h(195): const typename MatrixType::Nested m_matrix; Sparse\SparseBlock.h(359): const typename MatrixType::Nested m_matrix; Sparse\SparseSelfAdjointView.h(151): const typename MatrixType::Nested m_matrix; Should we remove the const from all of them!?
Yes, I think so, unless you see a reason not to. My 'business plan' for 3.1 is 3 phases: 1. make this kind of big sweeping changes to clean up and stabilize our internals (most important is bug 99) 2. document our internals: write good developer documentation 3. work on remaining 3.1 blockers while new people start reading about our internals and can much better help us than they could before 4. ??? 5. profit
for the record several have been "magically" removed already, still remains: Eigen/src/Core/Block.h: const typename XprType::Nested m_xpr; Eigen/src/Core/IO.h: const typename ExpressionType::Nested m_matrix; Eigen/src/Core/Transpositions.h: const typename IndicesType::Nested m_indices; Eigen/src/Eigen2Support/Minor.h: const typename MatrixType::Nested m_matrix; Eigen/src/misc/SparseSolve.h: const typename Rhs::Nested m_rhs; Eigen/src/misc/SparseSolve.h: const typename Guess::Nested m_guess; Eigen/src/SparseCore/SparseBlock.h: const typename MatrixType::Nested m_matrix; since this is not critial -> 3.2
no need to delay 3.2 for that.
https://bitbucket.org/eigen/eigen/commits/87b426b9228c/ https://bitbucket.org/eigen/eigen/commits/71d2e8a2808b/ Summary: Bug 178: remove additional const on nested expression, and remove several const_cast. Good enough for 3.3.
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/178.