Different types of *

Possible Duplicate:
What are rvalues, lvalues, xvalues, glvalues, and prvalues?

The standard states:
3.2 The this pointer 
1 In the body of a non-static (9.3) member function, 
the keyword this is a non-lvalue expression whose value is the address of the 
object for which the function is called.

What is the difference between rvalue,lvalue, non-rvalue, non-lvalue?

How many types of such *values are there? I mean i heard there xvalues also.

Need to understand this badly. And how are these related to temporaries and lambdas?

Sorry if i sound repetitive, perplexed, oxymoron-ic and redundant.


An lvalue is something that can appear on the l eft-hand side of an assignment. An rvalue is something that can appear on the r ight-hand side of an assignment. this is a non-lvalue expression in the sense that you aren't allowed to assign to it: you can't say this = new Foo(); , for instance.

[EDITED to add: the above paragraph is wrong, though it may be a useful mnemonic and does reflect the origins of the term. See comments below. The references below, however, are correct.]

See section 3.10 of the standard, at least if the draft I'm looking at is representative. Section [basic.lval]. It begins: "Every expression is either an lvalue or an rvalue."

That's in the existing standard. C++0x seems likely to introduce: xvalues, glvalues, prvalues. See What are rvalues, lvalues, xvalues, glvalues, and prvalues? for more abuot this.

链接地址: http://www.djcxy.com/p/73006.html

上一篇: 在C ++中传递值或传递常量引用会更好吗?

下一篇: 不同类型的*