TheIdeasMan wrote: |
---|
In the cppreference, I observe they use the word "either" rather than "and". |
Yes, but they talk about
glvalues and
rvalues.
cppreference wrote: |
---|
A glvalue expression is either lvalue or xvalue. |
An rvalue expression is either prvalue or xvalue. |
This is not incompatible with what I said about
xvalues being both
glvalues and
rvalues.
Note that the standard shows the lines as arrows so it's not the same relationship in both directions.
Here is the same structure, but involving animals instead of expressions, which might help illustrate how I think the tree works:
animal
/ \
/ \
mammal aquatic
/ \ / \
/ \ / \
elephant whale shark |
A
whale is both
aquatic and it is a
mammal. It is not just one or the other.
TheIdeasMan wrote: |
---|
mbozzi's table also ties in with the Stroustrup article I linked earlier, where identity and movable were part of the notation, which eventually lead to the naming of the value categories. |
I had not read Stroustrup's article before. I did and now it's much clearer. Now I'm even more convinced that I'm right about all
xvalues being both
glvalues and
rvalues. What mbozzi wrote does not go against this.
I found the following quote, on the naming of
xvalues, interesting:
Stroustrup wrote: |
---|
They are important to people working with the (draft) standard text, but are unlikely to become a household name. We didn’t find any real constraints on the naming to guide us, so we picked ‘x’ for the center, the unknown, the strange, the xpert only, or even x-rated. |
This strengthens the feeling I have that most programmers don't need to have a good understanding of the value categories (except an informal idea of what "lvalues" and "rvalues" are). It's often enough to think that
T() creates a temporary, and if it doesn't we just think of it as (guaranteed) "copy ellision" even though it's not exactly how the standard explains it. I know I can move from a non-const variable by using std::move, I don't need to know what value category that expression has.
If you think I'm wrong, and that I will benefit a lot in my day-to-day programming from having a solid understanding on how the value categories work and interact with each other in different contexts, then please tell me. I'm obviously biased and I know it's hard to see the benefit of something before learning it properly.