The literal answer is probably because literals predate the addition of const
to the language, so naturally they are not const
.
But the practical answer is - const
prvalues are fundamentally strange things. You cannot create them from any of the fundamental types, but you can have a const
prvalue of class type. But... why? Typically, we make things const
to prevent further modifications right. But if it's a prvalue, it's not even a thing with identity - who is going to be there to observe its unintended modification? const
prvalues prevent moving - because they're const
, so you can't move from them, so its a premature pessimization.
Note that the one thing that could go wrong, that a hypothetical const
literal would prevent, is already explicitly forbidden by the language:
void foo(int&);
foo(42); // error
But rather than making 42
const
, the language made lvalue references non-const
not allowed to bind to rvalues.