Title
Confusing specification of the meaning of decltype
Status
nad
Section
9.2.9.3 [dcl.type.simple]
Submitter
Vera Lychagina

Created on 2007-12-17.00:00:00 last changed 203 months ago

Messages

Date: 2008-02-15.00:00:00

Rationale (February, 2008):

The text is clear enough. In particular, both of these points are illustrated in the last two lines of the example contrasting decltype(a->x) and decltype((a->x)): in the former, the expression has no parentheses, thus satisfying the requirements of the first bullet and yielding the declared type of A::x, while the second has parentheses, falling into the third bullet and picking up the const from the object expression in the member access.

Date: 2022-11-20.07:54:16

The first bullet of 9.2.9.3 [dcl.type.simple] paragraph 4 says,

  • if e is an id-expression or a class member access (7.6.1.5 [expr.ref]), decltype(e) is the type of the entity named by e.

There are two clarifications to this specification that would assist the reader. First, it would be useful to have a note highlighting the point that a parenthesized expression is neither an id-expression nor a member access expression.

Second, the phrase “the type of the entity named by e” is unclear as to whether cv-qualification in the object or pointer expression is or is not part of that type. Rephrasing this to read, “the declared type of the entity,” or adding “(ignoring any cv-qualification in the object expression or pointer expression),” would clarify the intent.

History
Date User Action Args
2008-03-17 00:00:00adminsetmessages: + msg1632
2008-03-17 00:00:00adminsetstatus: open -> nad
2007-12-17 00:00:00admincreate