Microsoft KB Archive/240869

= BUG: C2667 and C2668 on Partial Ordering of Function Templates =

Article ID: 240869

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft Visual C++ 5.0 Enterprise Edition
 * Microsoft Visual C++ 5.0 Professional Edition
 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition

-



This article was previously published under Q240869



SYMPTOMS
You may get the following error message if you try to use partial ordering of template functions:

error C2667: 'f' : none of 3 overload have a best conversion error C2668: 'f' : ambiguous call to overloaded function

Please refer to the sample code in the "More Information" section for details.



CAUSE
The compiler does not support partial ordering of template functions as specified in the C++ Standard, section 14.5.5.2, which is quoted below: 1 - If a function template is overloaded, the use of a function template specialization might be ambiguous because template argument deduction may associate the function template specialization with more than one function template declaration. Partial ordering of overloaded function template declarations is used in the following contexts to select the function template to which a function template specialization refers:
 * during overload resolution for a call to a function template specialization;
 * when the address of a function template specialization is taken;
 * when a placement operator delete that is a template function specialization is selected to match a placement operator new;
 * when a friend function declaration, an explicit instantiation or an explicit specialization refers to a function template specialization



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
The following sample code demonstrates the error: //test.cpp // compiler option needed: none

template void f(T); template void f(T*); template void f(const T*);

void m { const int *p; f(p); //   f(const   T*)  is more specialized //  than  f(T)  or  f(T*) }

