News for hackers. Stuff that matters.
Re:Lvalues, rvalues, glvalues, prvalues, xvalues, help (2018) by rocqua on Thursday April 11, 2019 @08:37AM (#19633759)
Is it totally exactly true that a `glvalue` is either an `xvalue` or a `lvalue` and nothing else?

Similarly, is a `rvalue` either a `xvalue` or a `prvalue`?

Re:Lvalues, rvalues, glvalues, prvalues, xvalues, help (2018) by dbaupp on Thursday April 11, 2019 @09:01AM (#19633982)
Yes, section 8.2.1 "Value Category" (page 80) of the C++17 standard[0] defines the terms as:

(1.1) - A glvalue is an expression whose evaluation determines the identity of an object, bit-field, or function.

(1.2) - A prvalue is an expression whose evaluation initializes an object or a bit-field, or computes the value of the operand of an operator, as specified by the context in which it appears.

(1.3) - An xvalue is a glvalue that denotes an object or bit-field whose resources can be reused (usually because it is near the end of its lifetime).

(1.4) - An lvalue is a glvalue that is not an xvalue.

(1.5) - An rvalue is a prvalue or an xvalue.

It also has a diagram summarising it (equivalent to the one in the article, but the article's is clearer IMO):

         expression
          /      \
      glvalue    rvalue
       /    \    /    \
   lvalue   xvalue    prvalue
Where every expression is in one of the three value categories in the bottom row.

[0]: available free as a late draft: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n471...

Re:Lvalues, rvalues, glvalues, prvalues, xvalues, help (2018) by rocqua on Thursday April 11, 2019 @12:38PM (#19636394)
Thanks, I actually recall seeing that diagram.

I agree that the article is clearer. Because I didn't get it when I saw that diagram, but I do get it after reading the article.