[eigen] correct use of rvalue referenes

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


Well, I have to admit that I did something seriously wrong the last
time and that MSVC's implementation is absolutely correct!

Only rvalue reference can be converted to rvalue references and here
'd' is an lvalue. The correct implementation would be to use
std::move.

On Wed, Aug 4, 2010 at 12:04 PM, Hauke Heibel
<hauke.heibel@xxxxxxxxxxxxxx> wrote:
> struct Base {};
> struct Derived : public Base {};
> void buggy(Base&& b) {}
>
> int main()
> {
>  Derived d;
>  buggy(d);
> }

The main should look like this:

int main()
{
 Derived d;
 buggy(std::move(d)); // convert the lvalue to an rvalue
 buggy(Derived()); // work with a real rvalue
}

Regards,
Hauke



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