How are unqualified non-id identifiers classified in terms of lvalues ​​and rvalues?

It seems that the standard does not explicitly say about the expression categories of some unqualified identifiers. On the other hand, an identifier that is one of the unqualified identifiers is classified as follows:

The result is an lvalue if the object is a function, variable, or data item, and a prvalue otherwise.

Then, how about another unqualified-id-operator-function-id, convert-function-id, literal-operator-id, ~ class-name, ~ decltype-specifier, template-id?

+3


source to share


1 answer


This is recognized by Core Working Group # 536 , which was introduced almost 10 years ago. Therefore, this was probably not considered important enough to fix.

More importantly, some types of id expressions are not described in 5.1.1 [expr.prim.general]. The structure of this section is that the result, type, and lvalue-ness are specified for each case covers [...]

This processing leaves the entire unqualified-id unspecified (operator-id, function-id, and template-id) [...]

- CWG 536




From the behavior of various compilers, we can assume that all of these expressions follow the rule for identifiers:

The expression type is the type of the identifier. The result is the object indicated by the identifier. The result is an lvalue if the object is a function, variable, or data item, and a prvalue otherwise.

- post-N4296 [expr.prim.general] p13

By the way: all these expressions, except for template identifiers, can only refer to functions. Template names can also refer to variables. Both ID templates and regular IDs can refer to classes and enums, which confused me a bit (could there be expressions like int

? Are they prvalues?)

0


source







All Articles