New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Partial ordering rules for packs in [temp.deduct.type] #4014
Comments
It is correct that the original template argument deduction for function calls is on a per-parameter/argument basis. Using the thus-deduced template parameters, a specialization (of the declaration) is generated which is then used as the input for further overload resolution, which may consider partial ordering as a tie-breaker for the entire candidate (= specialization of the function template declaration). At that point, the entire declaration is in view, and [temp.func.order] p2 says the "function type" is used for partial ordering. |
@jensmaurer Hm, are you sure? http://eel.is/c++draft/temp.deduct.partial#3 says that the deduction for partial ordering is done on a per parameter/argument basis in the context of a function call |
Good point. However, this doesn't seem to be an editorial issue. |
The example given at the end of temp.deduct.type p10 is a non-call context, though, where the rule does apply as specified. So, where exactly is the editorial problem? |
@jensmaurer The problem itself would arise in the following example: template<typename T>
int f(T); // #1
template<typename... T>
int f(T...); // #2
int a = f(1); // calls #1 Our intent here is that As for the editorial nature of this issue, that example pretty clearly demonstrates what we want to happen. CWG has also stated what we want to happen in CWG 1825 and CWG 1395. |
[temp.deduct.partial] p3 says that we use individual parameters, but then [temp.deduct.partial] p8 has special rules for variadic templates, and look beyond the individual parameter's P/A pair. |
Yup, it effectively says we "look ahead" to match trailing packs. However, it still doesn't use the entire function type, so [temp.deduct.type] p10 wouldn't apply. |
My assumption is that we don't need/want [temp.deduct.type] p10 to apply for this case, since we already have similar wording in [temp.deduct.partial] p8 for matching variadics. |
The wording in p8 doesn't cause the deduction to fail (as we intend it to) meaning that it would have no effect on the example I provided. |
The wording in [temp.deduct.type] p10 that effectively states "during partial ordering, a function parameter pack is less specialized than
N
matching function parameters" doesn't apply to partial ordering the the context of a function call, since rather than using the entire function type for deduction, only the types of the parameter with arguments in the call are used, meaning thatP
does not have a form that contains(T)
unless the type of the parameter itself was compounded from a function type.The text was updated successfully, but these errors were encountered: