Rule 14–8–1 and dissimilar overloaded templates - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18) +--- Forum: MISRA C++:2008 rules (https://forum.misra.org.uk/forumdisplay.php?fid=19) +---- Forum: 6.14 Templates (C++) (https://forum.misra.org.uk/forumdisplay.php?fid=142) +---- Thread: Rule 14–8–1 and dissimilar overloaded templates (/showthread.php?tid=545) |
Rule 14–8–1 and dissimilar overloaded templates - James Widman - 03-07-2008 Hi all, I suspect that the net cast by rule 14–8–1 is too wide. For example, I don't think it's helpful to label the following as "non-compliant": Code: template void f ( T ); // #1 In this case, the specialization of #1 cannot get you into trouble. In the actual example given for 14–8–1, it is helpful to claim that the specialization is suspect because there is another template that would have been a better match if only the explicit template argument list had not been given, and a user (especially someone writing a call to the template) may not have an understanding of the type deduction rules sufficient to know which template would be selected when there are multiple matches and only one match is selected by partial ordering. But who, without the assistance of medication, would not just assume that #1 (in the example above) is being specialized in the explicit-specialization? Likewise, who, in the absence of default arguments and in the absence of any other overload, would not just assume that #1 would be called when the call expression contains only one argument? I recommend changing the wording of the rule to: Quote:An overloaded function template shall not be explicitly Re: Rule 14–8–1 and dissimilar overloaded templates - misra cpp - 07-10-2015 It is agreed that the rule currently covers cases that are not ambiguous. This rule will be reviewed for the next revision of MISRA C++. |