Since it is not possible to define a reference to a reference, why is the 8th line of this code not throwing an error? My understanding is that the aforementioned statement is equivalent to
double &&ref2 = value;
which should throw an error.
#include <iostream>
using namespace std;
int main()
{
double value = 12.79;
typedef double& ref_to_double;
ref_to_double ref = value; // Equivalent to double &ref = value;
ref_to_double &ref2 = value;
ref2 = 12.111;
cout << value << endl;
}
Output:
12.111
Follow-up question: Replacing the 8th line with ref_to_double &&ref2 = value;
is also not producing a compile-time error. Why is this so?