Re: [eigen] Matrix multiplication seems to be exceptionally slow in one specific case

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


On Tue, 17 Jun 2014, Christoph Hertzberg wrote:

 auto AB = A*B;          // shall this evaluate into a temporary?

Write auto&& (or auto const&) if you don't want value semantics.

Wouldn't that lose C++11 compatibility?

I believe this is already fine in C++11. The main drawback of using references there is:
auto && x = + f(y);
where f(y) returns a prvalue (a temporary) and operator+ returns a reference to its argument (tempting despite the danger). In this case x becomes a dangling reference, while "auto x" would have safely made a copy before the temporary got out of scope.

--
Marc Glisse



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