[eigen] Can we prevent that this compiles?

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


I've stumbled over a nasty little thing that resulted in wrong results. It was caused, since I passed the wrong template parameter to Replicate and due to implicit conversion of MatrixXd::RowXpr into MatrixXd.

Here is the bad code piece:

MatrixXd m = MatrixXd::Random(2,10);
Replicate<MatrixXd,2,1> first_row_twice(m.row(0));

Whereas it should be:

MatrixXd m = MatrixXd::Random(2,10);
Replicate<MatrixXd::RowXpr,2,1> first_row_twice(m.row(0));

My question is whether somebody has an idea of preventing the first version to compile? I fear that it will not be possible to prevent the compilation which is unfortunate since this error is quite subtle...

Cheers,
Hauke


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