Title
Template validity rules for templated entities and alias templates
Status
drwp
Section
13.8.1 [temp.res.general]
Submitter
Richard Smith

Created on 2023-03-29.00:00:00 last changed 12 months ago

Messages

Date: 2023-05-12.20:59:33

Proposed resolution (approved by CWG 2023-05-12):

Change in 13.8.1 [temp.res.general] paragraph 6 as follows:

The validity of a template templated entity may be checked prior to any instantiation. [Note 3: Knowing which names are type names allows the syntax of every template to be checked in this way. —end note]

The program is ill-formed, no diagnostic required, if:

  • no valid specialization, ignoring static_assert-declarations that fail (9.1 [dcl.pre]), can be generated for a template templated entity or a substatement of a constexpr if statement (8.5.2 [stmt.if]) within a template templated entity and the innermost enclosing template is not instantiated, or
  • no specialization of an alias template (13.7.8 [temp.alias]) is valid and no specialization of the alias template is named in the program, or
  • any constraint-expression in the program, introduced or otherwise, has (in its normal form) an atomic constraint A where no satisfaction check of A could be well-formed and no satisfaction check of A is performed, or
  • every valid specialization of a variadic template requires an empty template parameter pack, or
  • a hypothetical instantiation of a template templated entity immediately following its definition would be ill-formed due to a construct (other than a static_assert-declaration that fails) that does not depend on a template parameter, or
  • the interpretation of such a construct in the hypothetical instantiation is different from the interpretation of the corresponding construct in any actual instantiation of the template templated entity.

Date: 2023-06-15.00:00:00

[Accepted as a DR at the June, 2023 meeting.]

Subclause 13.8.1 [temp.res.general] paragraph 6 specifies rules to determine when a template is valid, but the specification is in terms of "instantiation". However, some kinds of templates (namely alias templates) are not instantiated.

Further, the rule discusses only templates, but should apply to any templated entity.

History
Date User Action Args
2023-12-19 10:15:28adminsetstatus: dr -> drwp
2023-07-16 13:00:43adminsetstatus: ready -> dr
2023-05-12 20:59:33adminsetmessages: + msg7279
2023-05-12 20:59:33adminsetstatus: open -> ready
2023-03-29 00:00:00admincreate