No, the return value of a function is an l-value if and only if it is a reference (C ++ 03). (5.2.2 [expr.call] / 10)
If the return type was basic, then this will be a compilation error. (5.17 [expr.ass] / 1)
The reason for this is that you are allowed to call member functions (even non- const member functions) on r-values โโof the class type, and the purpose of foo is a specific implementation member function: foo& foo::operator=(const foo&) . The restrictions for operators in Section 5 apply only to built-in operators (5 [expr] / 3), if overload resolution selects an overloaded function call for an operator, then the restrictions for this function call apply instead.
That is why it is sometimes recommended to return class type objects in the form of const objects (for example, const foo q(); ), however this can have a negative effect on C ++ 0x, where it can interfere with the movement semantics, as they should.
Charles Bailey May 24 '11 at 2:26 pm 2011-05-24 14:26
source share