Despite the intentions of the P0091: Template argument deduction for class templates proposal to align the behavior of function and class templates, partial deduction for class templates remains unworkable.
Consider the class template:
When using a helper function for ease of use:
Code such as:
compiles successfully. However, in more recent compiler versions, partial deduction (i.e., auto b = helper<5>(buffer);) fails, suggesting that partial class template argument deduction is indeed not supported.
This limitation stems from concerns raised regarding potential confusion in cases like:
Therefore, while the proposal initially aimed to unify deduction behavior, partial deduction for class templates remains unworkable due to potential ambiguity issues.
The above is the detailed content of Why is Partial Class Template Argument Deduction Still Unworkable?. For more information, please follow other related articles on the PHP Chinese website!