The following code does not compile:
typedef int& int_ref;
int main()
{
const int& ic = 1;
const int_ref icc = 2;
}
error: non-const lvalue reference to type 'int' cannot bind to a temporary of type 'int'.
When I move the const into the typedef it does compile, like so:
typedef const int& int_ref;
int main()
{
const int& ic = 1;
int_ref icc = 2;
}
Why??