This is admittedly a nit-picky question that is mainly driven by curiosity. Suppose we have the following:
int x = 5;
int&& xref = std::move(x);
std
A temporary is constructed, initialised from the value of the literal, and it lasts as long as the reference. You can do what you like with this object.
In terms of lifetime, this is just the same as if you'd written const int& x = 5
; only, there, the fact that you're working with an automatically-created temporary object is masked because the const
prevents you from proving it with a mutation.
[C++14: 8.5.3/5]:
[..] IfT1
is a non-class type, a temporary of type “cv1T1
” is created and copy-initialized (8.5) from the initializer expression. The reference is then bound to the temporary. [..]
int&& xref = 5;
... creates a temporary, initialized with 5, whose lifetime is extended to the end of the block.
The assignment
xref = 10;
changes the value of the still living temporary.