Let's say we have a function:
struct A {
int m;
};
A&& f();
As far as I know the expressions:
f();
f().m;
are both xvalue. But why? Why aren't they prvalue? I'm a little bit confused.
Let's say we have a function:
struct A {
int m;
};
A&& f();
As far as I know the expressions:
f();
f().m;
are both xvalue. But why? Why aren't they prvalue? I'm a little bit confused.
Copyright © 2021 Jogjafile Inc.
Because you are returning by reference, not by value, from
f. This implies that theAhas a lifetime longer thanf(), e.g.or
But not
In
f().m;, the use ofminherits the value category of the earlier sub-expression, as normal for member access.