Functions returning lvalues, always return lvalue references

It means what it says!

There is no way to make a function, such that its return type is not T&, yet calling it results in an lvalue expression.

Every other return type results in the function call being an rvalue expression.

This is intuitive when you consider that the only way to "return" something that already exists, is by reference — the result of a function call is otherwise always a "temporary", whether because it's copying some local variable, or because it's moving from some local variable.

The would-be exception to this rule, returning T&&, doesn't apply either because these produce rvalue expressions (which is what makes move semantics work, since only rvalue expressions can go on to bind to T&& parameters).

Scott is reporting a consequence of the rules of the language, and telling us that the same consequence was used as a justification for one of the rules of decltype.

Arguably, he could have more clearly phrased it thus:

The only functions whose calls evaluate to lvalues, are those that return lvalue references.

Tags:

C++