This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 112e. See for the official list.


2777. Type of id-expression denoting a template parameter object

Section: 13.2  [temp.param]     Status: open     Submitter: Jim X     Date: 2023-07-26

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 [dcl.type.decltype] paragraph 1:

For an expression E, the type denoted by decltype(E) is defined as follows:

Possible resolution:

Change in [] 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 case, the type of the expression is the type of the entity.