Registered Member
|
Hi,
I create a templated function which signature is:
I call it as:
where lnComp is a RowVector (a typedef to a one row Matrix) and tik_ is a Matrix<double>. I get the following error:
While the following code compiles without problem (Real is a typedef for double):
The compiler is gcc. What I do not understand is why the compiler does not find any function with a RowXpr parameter, and only finds a candidate with Eigen::Block for the second parameter. Since logToMulti is templated, shouldn't the candidate with RowXpr as the second parameter be automatically generated ? Regards |
Moderator
|
In c++ temporaries cannot be bound to a non const reference. Here, tik_.row(i) returns a temporary Block<> object referencing the i-th row of tik. If you really need read-write object, then either use the Eigen::Ref<> class, or use a const ref with a const_cast, or you can also name the object, in c++11:
auto ri = tik_.row(i); logToMulti(lnComp,ri); |
Registered Member
|
Thank you for your explanation ! I can now link this problem to what is presented on the doc: http://eigen.tuxfamily.org/dox-devel/To ... Types.html .
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]