Title
Requirements for simple-template-id used as a class-name
Status
cd5
Section
Clause [11] [class]
Submitter
CWG

Created on 2016-06-22.00:00:00 last changed 47 months ago

Messages

Date: 2018-03-15.00:00:00

Proposed resolution (March, 2018):

  1. Change _N4868_.6.4.1 [basic.scope.declarative] paragraph 1 as follows:

  2. Every name is introduced in some portion of program text called a declarative region, which is the largest part of the program in which that name is valid valid, that is, in which that name may be used as an unqualified name to refer to the same entity. In general...
  3. Add the following as a new paragraph after 13.3 [temp.names] paragraph 7:

  4. A template-id that names an alias template specialization is a type-name.

    A template-id is valid if

    • there are at most as many arguments as there are parameters or a parameter is a template parameter pack (13.7.4 [temp.variadic]),

    • there is an argument for each non-deducible non-pack parameter that does not have a default template-argument,

    • each template-argument matches the corresponding template-parameter (13.4 [temp.arg]),

    • substitution of each template argument into the following template parameters (if any) succeeds, and

    • if the template-id is non-dependent, the associated constraints are satisfied as specified in the next paragraph.

    A simple-template-id shall be valid unless it names a function template specialization (13.10.3 [temp.deduct]). [Example:

      template<class T, T::type n = 0> class X;
      struct S {
        using type = int;
      };
      using T1 = X<S, int, int>;  // error: too many arguments
      using T2 = X<>;             // error: no default argument for first template parameter
      using T3 = X<1>;            // error: value 1 does not match type-parameter
      using T4 = X<int>;          // error: substitution failure for second template parameter
      using T5 = X<S>;            // OK
    

    end example]

  5. Change 13.10.3 [temp.deduct] paragraph 2 as follows, converting from bullets to running text:

  6. When an explicit template argument list is specified, if the template arguments are not compatible with the template parameter list or do not result in a valid function type as described below given template-id is invalid (13.3 [temp.names]), type deduction fails. Specifically, the following steps are performed when evaluating an explicitly specified template argument list with respect to a given function template:

    • If the specified template arguments do not match the template parameters in kind (i.e., type, non-type, template), or if there are more arguments than there are parameters and no parameter is a template parameter pack, or if there is not an argument for each non-pack parameter, type deduction fails.

    • If any non-type argument does not match the type of the corresponding non-type template parameter, and is not convertible to the type of the corresponding non-type parameter as specified in 13.4.3 [temp.arg.nontype], type deduction fails.

    • The specified template argument values are substituted for the corresponding template parameters as specified below.

Date: 2018-06-15.00:00:00

[Accepted as a DR at the June, 2018 (Rapperswil) meeting.]

There is currently no requirement that a simple-template-id used as a class-name (Clause 11 [class] paragraph 1) must have template arguments for every template parameter that does not have a default template argument.

History
Date User Action Args
2020-12-15 00:00:00adminsetstatus: ready -> cd5
2018-04-11 00:00:00adminsetmessages: + msg6177
2018-04-11 00:00:00adminsetstatus: drafting -> ready
2016-06-22 00:00:00admincreate