I am reading the Wikipedia entry about decltype, and I can't understand the following passage:
Similarly to the sizeof operator, the operand of decltype is unevaluated.[11] Informally, the type returned by decltype(e) is deduced as follows:[2]
- If the expression e refers to a variable in local or namespace scope, a static member variable or a function parameter, then the result is that variable's or parameter's declared type
- Otherwise, if e is an lvalue, decltype(e) is T&, where T is the type of e; if e is an xvalue, the result is T&&; otherwise, e is a prvalue and the result is T.
it first says: "If the expression e refers to a variable in local or namespace scope", then it follows by "Otherwise, if e is an lvalue". For me it implies that a variable from local scope is not an lvalue. Am I right? - I always thought local variables are lvalues.
Maybe item 2 refers to case where we use decltype((e)) - with double parentheses? I suppose this is what is said later in this wiki: "More formally, Rule 1 applies to unparenthesized id-expressions and class member access expressions."