2

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.

Community
  • 1
  • 1
Sadique
  • 22,572
  • 7
  • 65
  • 91
  • Duplicate of http://stackoverflow.com/questions/3601602/what-are-rvalues-lvalues-xvalues-glvalues-and-prvalues – Mark B Mar 15 '11 at 16:43

1 Answers1

-2

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.

Community
  • 1
  • 1
Gareth McCaughan
  • 19,888
  • 1
  • 41
  • 62
  • 1
    The first sentence isn't entirely true. There are also non-modifiable lvalues, like arrays, that cannot be assigned to. – James McNellis Mar 15 '11 at 16:52
  • 2
    Not true. While the origins of the name can indeed be traced back to the LHS of assignment, the definition of the standard term has absolutely nothing to do with LHS of assignment. The name "lvalue" was retroactively reinterpreted as "location-lalue". I.e. lvalue is an entity that has a location (an address) in storage. This is for C though. C++ made some changes in the definitions. – AnT stands with Russia Mar 15 '11 at 17:20
  • Whoops, quite right. Downvote richly deserved. Thanks for the correction, James and Andrey. – Gareth McCaughan Mar 15 '11 at 17:42