开发者

Different types of *-values [duplicate]

开发者 https://www.devze.com 2023-02-17 12:14 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: What are rvalues, lvalues, xvalues, glvalues, and prvalues?
This question already has answers here: Closed 11 years ago.

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开发者_JAVA百科 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号