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

Created on 2012-04-16.00:00:00 last changed 90 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 _N4868_.13.7.6 [temp.class.spec] paragraph 8:

  • ...

  • 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 (_N4868_.13.7.6.3 [temp.class.order]).

  • ...

Date: 2021-02-24.00:00:00

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 _N4868_.13.7.6 [temp.class.spec], but it is not more specialized than the primary template. However, _N4868_.13.7.6.2 [temp.class.spec.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