Title
Trailing requires-clause can refer to function parameters before they are substituted into
Status
open
Section
13.10.3.1 [temp.deduct.general]
Submitter
Richard Smith

Created on 2023-07-14.00:00:00 last changed 12 months ago

Messages

Date: 2023-07-15.20:32:39

Suggested resolution:

Function parameters should be instantiated when they are needed by a satisfaction check of an atomic constraint or (recursively) by another function parameter.

Date: 2023-07-14.00:00:00

After the application of issue 2369, satisfaction for a trailing requires-clause is checked prior to substitution into the function type. Subclause 13.10.3.1 [temp.deduct.general] paragraph 5 specifies:

If the function template has associated constraints (13.5.3 [temp.constr.decl]), those constraints are checked for satisfaction (13.5.2 [temp.constr.constr]). ... If type deduction has not yet failed, then all uses of template parameters in the function type are replaced with the corresponding deduced or default argument values.

However, the associated constraints can refer to parameters, thus substitution into the parameter types must have been already done at the time of checking. Consider:

  template<typename T> void f(T t) requires (sizeof(t) == 5) {}
History
Date User Action Args
2023-07-15 20:32:39adminsetmessages: + msg7379
2023-07-14 00:00:00admincreate