Given the code below, everything works. How come that the variable d is reference to int? What is going on?
int main()
{
int a= 10;
int &&b =
There is a special rule in type deduction. In auto &&d = a;
"auto&&" is an rvalue reference to a non-const non-volatile type and "a" is an lvalue, then this special rule is applied: the type of "a" is treated as int& instead of int. Then as usual choose the type of "auto" to be identical to the type of "a", that is int&. So the type of "auto&&" is int& according to reference collapsing as mentioned by bames53.