I'm new to C++ and this is my first question here so bear with me please ... I have been reading about lvalue and rvalue for a while and I think I understand most of it but there is bit that still confuses me ... so my question will be specific
rvalue references are considered lvalue (this part I understand) but functions that return rvalue references are considered rvalue (or xvalue to be specific) for instance:
int x = 32; int& Lref = x; // Lref is lvalue ... ok int& funcA(); // calling funcA() is lvalue ... ok int&& Rref = 32; // Rref is lvalue ... ok I got this int&& funcB(); // calling funcB() is rvalue ... Why? So the question is: why calling funcB() which return rvalue reference is considered rvalue ?
Thanks in advance.
rvalue references are considered lvaluethey don't otherwise we wouldn't have 2 different typesLrefis a lvalue reference, but32isn't and it won't indeed compile. You'd needconst&or&&, as you also show.