C++0x: RValue references cannot be bound to lvalues
I have recently been reading up about the new language features of C++0x. One of these new features allows you to create references to rvalues, i.e:
There is a wealth of information about these and why they are useful:
However, the semantics of rvalue references have slightly changed since these documents were published. You used to be able to bind an lvalue to an rvalue reference, i.e:
This is no longer allowed and will generate a compiler error (more details here). As a result, several online sources of information (including the above documents) now contain broken code and this can be an additional source of confusion when experimenting with this new language feature. So take care - Visual Studio 2010 uses these updated semantics, and so does GCC (at the time of writing, I tested this with version 4.5.2).