References to lvalue constants can bind to rvalues. Rvalues, like your literal 1 , do not have a constant alias, so if you need to modify it, you will not be able to observe the effect, but if you promise not to change it (namely, by accessing it through a permalink), you can still to have completely reasonable code and why this binding is allowed.
(You can also associate rvalues ββwith (mutable) rvalue references: void function(int &&) In this case, the rvalue reference becomes the (unique) value alias.)
Note also that without this rule, it would be impossible to initialize variables from functions returning prvalues, or to use copy initialization in general:
struct T { T(int); }; T f(); T x = 1;
Kerrek SB
source share