| Re: [eigen] Map const correctness now fixed |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
On 12/10/2010 10:58 AM, Benoit Jacob wrote:
2010/12/10 Jim Bosch<talljimbo@xxxxxxxxx>:On 12/10/2010 07:25 AM, Benoit Jacob wrote:This was bug 54, http://eigen.tuxfamily.org/bz/show_bug.cgi?id=54Excellent! This applies to Block, Transpose, and other things with DirectAccessBit set too, right?There only ever was a problem with Map, right? Then, if you pass a Map as argument to other expressions, like Block<Map<...> >, then yes everything propagates.
Here's an example:
void modify_matrix(Eigen::MatrixXd const & m) {
Eigen::Transpose<Eigen::MatrixXd> t = m.transpose();
b(0, 0) = 1.0;
}
My hope was that the const overload of MatrixBase::transpose() (and
block(), and part(), etc.) would return a "Transpose<const T>" rather
than a "Transpose<T> const" in order to ensure the above doesn't
compile, and allow one to inadvertently modify a matrix passed by const
reference.
Maybe one should never actually have a non-temporary Transpose or Block, but I've found doing that fairly useful in making code readable, and I've been hoping it is at worst neutral for performance purposes.
Jim
| Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |