In C ++ 11, if I try to do this:
int x = 5;
int && y = x;
It will not be able to compile with an error indicating that the r-value reference cannot be bound to an lvalue.
However, if I do this:
int x = 5;
auto && y = x;
It compiles without errors. Why is this happening? I tried to get the type y, but typeid()removes the reference attributes. auto &&automatically collapses in &or &&depending on what is assigned?
source
share