Title
Partial specialization of variadic class template
Status
cd3
Section
13.7.6 [temp.spec.partial]
Submitter
Jason Merrill

Created on 2012-04-16.00:00:00 last changed 131 months ago

Messages

Date: 2013-04-15.00:00:00

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

Date: 2012-10-15.00:00:00

Proposed resolution (October, 2012):

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

  • ...

  • The argument list of the specialization shall not be identical to the implicit argument list of the primary template.

  • The specialization shall be more specialized than the primary template (13.7.6.3 [temp.spec.partial.order]).

  • ...

Date: 2022-06-11.20:21:09

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.

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2013-10-14 00:00:00adminsetstatus: dr -> drwp
2013-05-03 00:00:00adminsetmessages: + msg4426
2013-05-03 00:00:00adminsetstatus: ready -> dr
2012-11-03 00:00:00adminsetmessages: + msg4070
2012-11-03 00:00:00adminsetstatus: open -> ready
2012-04-16 00:00:00admincreate