The difference should be whether or not the result is copied/moved. In the first case:
const int& x = y + 1;
The value of y+1
is essentially saved as a temporary value. We then initialize a reference x
to this temporary result. In the other case:
const int x = y + 1;
We compute y + 1
and initialize a constant variable x
with the value.
In practice with integers there will be no visible difference. If y+1
happened to be a large data structure, e.g., a class which is 1MB of data, this could make a significant difference.