Created on 2023-07-26.00:00:00 last changed 5 months ago
Proposed resolution (approved by CWG 2024-03-01):
Change in 7.5.5.2 [expr.prim.id.unqual] paragraph 3 as follows:
...[Note 4:If the entity is a template parameter object for a template parameter of type T (13.2 [temp.param]), the type of the expression is const T.—end note]In all other cases, the type of the expression is the type of the entity.
[Accepted as a DR at the March, 2024 meeting.]
The type of a template parameter object is specified to be const T in 13.2 [temp.param] paragraph 8:
An id-expression naming a non-type template-parameter of class type T denotes a static storage duration object of type const T, known as a template parameter object, whose value is that of the corresponding template argument after it has been converted to the type of the template-parameter. ...
However, it is unclear what the type of an id-expression is that refers to such an object. There is implementation divergence in the treatment of the following example:
struct A {}; template<auto a, auto x> // also consider A a and const auto x int f() { decltype(a) b; // also consider decltype((a)) A& rb = b; decltype(x) y; int& ry = y; } int x = f<A{}, 42>();
Note that non-type template parameters are handled specially for decltype, as specified in 9.2.9.6 [dcl.type.decltype] paragraph 1:
For an expression E, the type denoted by decltype(E) is defined as follows:
- ...
- otherwise, if E is an unparenthesized id-expression naming a non-type template-parameter (13.2 [temp.param]), decltype(E) is the type of the template-parameter after performing any necessary type deduction (9.2.9.7 [dcl.spec.auto], 9.2.9.8 [dcl.type.class.deduct]);
- ...
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-07-20 13:52:34 | admin | set | status: dr -> drwp |
2024-04-05 21:43:46 | admin | set | status: ready -> dr |
2024-03-20 05:31:40 | admin | set | status: tentatively ready -> ready |
2024-03-04 22:36:01 | admin | set | messages: + msg7630 |
2024-03-04 22:36:01 | admin | set | status: open -> tentatively ready |
2023-07-26 00:00:00 | admin | create |