Posts

Showing posts with the label value-categories

Xvalues vs prvalues: what does identity property add

Xvalues vs prvalues: what does identity property add I'm sorry for the broadness of the question, it's just that all these details are tightly interconnected.. I've been trying to understand the difference between specifically two value categories - xvalues and prvalues, but still I'm confused. Anyway, the mental model I tried to develop for myself for the notion of 'identity' is that the expression that has it should be guaranteed to reside in the actual program's data memory. Like for this reason string literals are lvalues, they're guaranteed to reside in memory for the entire program run, while number literals are prvalues and could e.g. hypothetically be stored in straight asm. The same seems to apply to std::move from prvalue literal, i.e. when calling fun(1) we would get only the parameter lvalue in the callee frame, but when calling fun(std::move(1)) the xvalue 'kind' of glvalue must be kept in the caller frame. std::move fun(1) fun(st...