This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-21


2972. Declarative nested-name-specifier naming a partial specialization

Section: 7.5.5.3  [expr.prim.id.qual]     Status: open     Submitter: Hubert Tong     Date: 2024-12-20

Consider:

  template <auto AX> struct A;
  template <int AX> struct A<AX> {
   static constexpr int X = AX;
  };
  template <int AX> const int A<AX>::X;   // #1

According to 7.5.5.3 [expr.prim.id.qual] paragraph 3, the declarative nested-name-specifier at #1 names the primary template and is thus ill-formed:

... If a nested-name-specifier N is declarative and has a simple-template-id with a template argument list A that involves a template parameter, let T be the template nominated by N without A. T shall be a class template.

However, the qualified-id is obviously intended to refer a member of the partial specialization.

Furthermore, the specification does not handle references to constrained partial specializations:

  template <typename T> struct A;
  template <typename T> concept C = true;

  template <typename T>
  requires C<T>
  struct A<T *> {
    struct B;
  };

  template <typename T>
  requires true && C<T>
  struct A<T *> {
    struct B;                   // #1
  };

  template <typename T>
  requires true && C<T>
  struct A<T *>::B {};         // ought to refer to #1