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

2024-11-11


1592. When do template parameters match?

Section: 13.4.4  [temp.arg.template]     Status: C++14     Submitter: Richard Smith     Date: 2012-12-03

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

According to 13.4.4 [temp.arg.template] paragraph 3,

A template-argument matches a template template-parameter (call it P) when each of the template parameters in the template-parameter-list of the template-argument's corresponding class template or alias template (call it A) matches the corresponding template parameter in the template-parameter-list of P.

There does not appear to be a formal definition of the criteria for whether two template parameters “match,” however, and there is implementation variance in the treatment of an example like

  struct A {
    typedef int T1;
    typedef int T2;
  };
  template<template<typename T, typename T::T1 N> class U>
  struct B {
    U<A, 0> u;
  };
  template<typename T, typename T::T2 N>
  struct C {
  };
  B<C> b; // ok?

Proposed resolution (June, 2013):

Change 13.4.4 [temp.arg.template] paragraph 3 as follows:

A template-argument matches a template template-parameter (call it P) when each of the template parameters in the template-parameter-list of the template-argument's corresponding class template or alias template (call it A) matches the corresponding template parameter in the template-parameter-list of P. Two template parameters match if they are of the same kind (type, non-type, template), for non-type template-parameters, their types are equivalent (13.7.7.2 [temp.over.link]), and for template template-parameters, each of their corresponding template-parameters matches, recursively. When P's template-parameter-list contains a template parameter pack...