[eigen] Why do const accessors return by value?

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi again,

Currently all of the MatrixBase const accessor functions return const Scalar, while the non-const version return (of course) Scalar&. Is there a rationale for returning by value in the const versions instead of const Scalar&? I don't like this inconsistent behavior. Sometimes I want to get a pointer to a chunk of memory in a Matrix so I can pass it to some low-level function, like foo( &mat(r, c) ). This breaks when mat is a const type like const Matrix&. I can also imagine wanting to use Eigen matrices with types that are not trivially cheap to copy (arbitrary precision types, for example), when returning by value may result in an unwanted copy.

Cheers,
Patrick


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/