I have couple of question about Eigen:
Does anyone know if there is any plan to support move semantics in Eigen anytime soon? Couldn't find anything on the TODO list of the Eigen3 web page. Right now I am using the
swap
trick to get rid of temporaries, likeMatrixXd foo() { MatrixXd huge_matrix(N,N); // size N x N where N is quite large // do something here with huge_matrix return huge_matrix; } MatrixXd A(N, N); A.swap(foo());
I'd very much like to write the above
swap
line in a C++11 style likeA = foo();
and not to have to worry about the temporary returned by
foo()
.- Can a C++98/C++03 compiler optimize the code
A = foo();
to get rid of this temporary? Or the safest bet is to useswap()
?
foo
takesA
as a param by const reference, so basically I have something likeA = foo(A)
. Copy elision should work even in this case, as the as-if rule is satisfied, is this correct? – Athamas