cppreference is said that: any expression that designates a temporary object after temporary materialization is xvalue expression (since C++17).
A prvalue of any complete type T can be converted to an xvalue of the same type T. This conversion initializes a temporary object of type T from the prvalue by evaluating the prvalue with the temporary object as its result object, and produces an xvalue denoting the temporary object.
What I suspect that I am not understood is that, from this quote, the temporary materialization conversion (prvalue->xvalue) produces an xvalue denoting to the temporary object. To clear what I am not fully understanding, I will provided a simple example:
const T& t = T();
The reference t
is bound to prvalue T()
. So a temporary of type T
gets created and initialized from this prvalue; then the reference will bind to that temporary. I think the temporary looks like this: and t
reference will bind to it:
T __tmp{ };
const T& t = __tmp;
Indeed the above two lines are happened implicitly, but in general, can I said that the expression __tmp
in the assignment const T& t = __tmp;
is xvalue expression?
Till now I am assuming I was true, if not, what does cppreference mean by "any expression that designates a temporary object, after temporary materialization is xvalue expression"? where's exactly the xvalue expression now? what does the word "designates" means in this context?