cplusplus / CWG

Core Working Group
23 stars 7 forks source link

CWG2770 [temp.deduct.general] trailing requires-clause can refer to function parameters before they're substituted into #364

Open zygoloid opened 1 year ago

zygoloid commented 1 year ago

Full name of submitter (unless configured in github; will be published with the issue):

Reference (section label): [temp.deduct.general]

Link to reflector thread (if any): https://lists.isocpp.org/core/2023/07/14525.php

Issue description:

After the application of CWG2369, satisfaction for a trailing requires-clause is checked prior to substitution into the function type. [temp.deduct.general]/5:

[...] If the function template has associated constraints ([temp.constr.decl]), those constraints are checked for satisfaction ([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.

But the associated constraints can refer to the parameters:

template<typename T> void f(T t) requires (sizeof(t) == 5) {}

Suggested resolution:

Among implementations that implement CWG2369, there seems to be no implementation variance: function parameters should be instantiated when they are needed by a satisfaction check of an atomic constraint or (recursively) by another function parameter.

jensmaurer commented 1 year ago

CWG2770