C++03 §4.2 N°1:
An lvalue or rvalue of type “array of N T” or “array of unknown bound of T” can be converted to an rvalue of type “pointer to T.” The result is a pointer to the first element of the array.
What has been confusing in this statement for a long time for me was that I didn't quite understand what an rvalue of array type would mean. That is, I couldn't come up with an expression whose type were an array and the result were an rvalue. I read this thread, which basically asks the same question and the accepted answer is "no, there is no rvalue of array type". I think I just might have a contradiction to this.
C++03 §5.2.5 N°4: (is about expression E1.E2)
If E2 is a non-static data member, and the type of E1 is “cq1 vq1 X”, and the type of E2 is “cq2 vq2 T”,the expression designates the named member of the object designated by the first expression. If E1 is an lvalue, then E1.E2 is an lvalue.
I assume that otherwise it is an rvalue (provided E2 is not a reference, that case is covered by §5.2.5 N°3
) and therefore...
struct A
{
int a[4];
};
A f()
{
A a;
return a;
}
int main()
{
f().a; //I think this is an rvalue of array type...
}
I see two options here:
Option1: I am correct, hurray, yay, cool. In this case the question is: are there other examples?
Option2: I am incorrect, in this case the question is: is this a defect of the standard?
I don't know about 1, but I really doubt about 2 because when they speak about function-to-pointer conversions they mention just lvalues of function types (obviously appreciating that there are no rvalues of such). So it's very likely they had thought abour rvalues of array types.
So, basically my question is whether or not I have come up with an example of rvalue of array type, and if not, please provide a valid one, which I stongly believe there exists.