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

2024-03-20


1495. Partial specialization of variadic class template

Section: 13.7.6  [temp.spec.partial]     Status: CD3     Submitter: Jason Merrill     Date: 2012-04-16

[Moved to DR at the April, 2013 meeting.]

Consider an example like

  template <int B, typename Type1, typename... Types>
  struct A;

  template<typename... Types>
  struct A<0, Types...> { };

  A<0,int,int> t;

In this case, the partial specialization seems well-formed by the rules in 13.7.6 [temp.spec.partial], but it is not more specialized than the primary template. However, 13.7.6.2 [temp.spec.partial.match] says that if exactly one matching specialization is found, it is used, which suggests that the testcase is well-formed. That seems undesirable; I think a partial specialization that is not more specialized than the primary template should be ill-formed.

If the example is rewritten so that both versions are partial specializations, i.e.,

  template <int B, typename... Types>
  struct A;

  template <int B, typename Type1, typename... Types>
  struct A<B, Type1, Types...> { }

  template<typename... Types>
  struct A<0, Types...> { };

  A<0,int,int> t;

There is implementation variance, with gcc and clang reporting an ambiguity and EDG choosing the second specialization.

Proposed resolution (October, 2012):

Add the following as a new bullet in 13.7.6.1 [temp.spec.partial.general] paragraph 9: