An int
needs to be converted to double
first. That conversion yields a prvalue temporary and these can't bind to references to non-const.
A reference to const will extend the lifetime of the temporary that would otherwise be destroyed at the end of the expression it was created in.
{
int a = 0;
float f = a; // a temporary float is created here, its value is copied to
// f and then it dies
const double& d = a; // a temporary double is created here and is bound to
// the const-ref
} // and here it dies together with d
If you're wondering what a prvalue is, here's a nice SO thread about value categories.