This reference is discarded when evaluating the type of expression (according to ยง 5/5), but this does not alter the fact that the expression for calling the function f() is an lvalue value. In clause 5.2.2 / 10 of the C ++ 11 standard:
A function call is an lvalue if the result type is a lvalue reference type or an rvalue reference to a type function, xvalue if the result type is an rvalue reference to an object type and otherwise a prvalue value.
In other words, the link is not discarded from the return type of the function itself, only from the type of the call expression of the function being evaluated (which, therefore, is int ).
The fact that a function returns an lvalue reference is what allows the type system to classify the corresponding function call expressions as lvalues, which in turn allows decltype add an lvalue reference to the type of the expression, thus giving int& .
source share