And int must first be converted to double . This conversion gives a temporary prvalue, and they cannot bind to non-const references.
A reference to const will extend the lifetime of a temporary object that would otherwise be destroyed at the end of the expression in which it was created.
{ 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 interested in what prvalue is, here is a good SO thread on value categories.
source share