Partial Ordering Procedure in Template Deduction
The partial ordering procedure determines the specialization relationship between function templates in C template deduction. It involves creating transformed function types for each template and using them for comparison.
Matching Arguments and Parameters:
The transformed function type of one template is matched against the original function template of the other template, using the following two cases:
Example:
Consider these two function templates:
template<typename T, typename U> void foo(T, U); // original #1 template<typename T> void foo(T const*, X<T>); // original #2
Matching the transformed types:
Conclusion: Overload #2 is more specialized than #1.
The above is the detailed content of How Does C Template Deduction Determine Specialization Using Partial Ordering?. For more information, please follow other related articles on the PHP Chinese website!