In short, you can just answer the part about identity, thanks. My main focus of this question is start from 2. about identity, I just tried to provide context/background of my current understanding so it may help you decide the depth when you're writing your answer.
I want to understand the big picture of type system and value categories in C++. I've searched/read many questions and resources online, but everyone has a distinct explanation, so I'm really confused. I'll list the part I can't grasp, if anyone could provide idea about
On cppreference.com, first line:
Objects, references, functions including function template specializations, and expressions have a property called type, which both restricts the operations that are permitted for those entities and provides semantic meaning to the otherwise generic sequences of bits.
my question:
- What does it mean an expression has a type? Is it the type of the final result after evaluation?
- I don't want to learn template at current stage, would this hinder learning about the basic part (from you expert's perspective)? It took me some time to realize that forwarding reference and rvalue reference are different thing, which the former is for template.
Value categories:
I read this answer of - What are rvalues, lvalues, xvalues, glvalues, and prvalues?, the phrase bother me a lot is identity, which also appears on cppreference.com - Value categories (Line 5, glvalue).
my question: can I say that
identity ==
everything I can assign a new value on it?- I saw people using the word address/pointer for it, but is that
has identity iff has address/pointer
? I want the precise term. - I came across the idea of bit-field when reading cppreference.com, it seems like given a bit-field struct
a
, its bit fielda.m
has no address? Is this the reason the word identity is used instead of address/pointer? - I found a blog post explaining this, but it's lvalue definition is counter-intuitive: an lvalue denotes an object whose resource cannot be reused, why not?
- I saw people using the word address/pointer for it, but is that