In the current draft, all interpretations of the deduction failures that occur in the deduction of template arguments for class templates want to refer to [temp.deduct] subclause. However, amount of rules defined in [temp.deduct] hints that they are just defined for function templates. partially cite them out here
The resulting substituted and adjusted function type is used as the type of the function template for template argument deduction. ... If the substitution results in an invalid type, as described above, type deduction fails.
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. If the substitution results in an invalid type, as described above, type deduction fails.
Only invalid types and expressions in the immediate context of the function type, its template parameter types, and its explicit-specifier can result in a deduction failure.
The deduction failure can occur in the deduction of template arguments of a class template, especially the deduction for partial specialization. Consider this case
template<class T, class U = void>
struct A{};
/* int fun(...); */
template<class T>
struct A<T, decltype((void)fun(T{}))>{};
int main(){
A<int> a;
}
[temp.spec.partial.match] p2
A partial specialization matches a given actual template argument list if the template arguments of the partial specialization can be deduced from the actual template argument list, and the deduced template arguments satisfy the associated constraints of the partial specialization, if any.
If it had not an appropriate fun, the substitution would result in an invalid expression, which causes the deduction failure. The cross-reference of deduce wants to borrow the rules defined for function templates. However, as pointed out above. The deduction failures only apply to function templates. A suggestion is that we should explicitly say a rewritten function template will be generated associated with the class template in order to make all rules for deductions apply to that context.
In the current draft, all interpretations of the deduction failures that occur in the deduction of template arguments for class templates want to refer to [temp.deduct] subclause. However, amount of rules defined in [temp.deduct] hints that they are just defined for function templates. partially cite them out here
The deduction failure can occur in the deduction of template arguments of a class template, especially the deduction for partial specialization. Consider this case
[temp.spec.partial.match] p2
If it had not an appropriate
fun
, the substitution would result in an invalid expression, which causes the deduction failure. The cross-reference ofdeduce
wants to borrow the rules defined for function templates. However, as pointed out above. The deduction failures only apply to function templates. A suggestion is that we should explicitly say a rewritten function template will be generated associated with the class template in order to make all rules for deductions apply to that context.