The following code compiles in Visual C++ and gcc, but fails with Code Warrior
The complaint is that the call to the template is ambiguous -- can't decide between doIt( M* ) and doIt( M const* ), even though in each case, the parameter is unambiguously cost or non-const. Irritatingly, if I supply the second template argument, it decides it is no longer ambiguous.
template< typename T1, typename T2 >
T1 const* doIt( T2 const* );
template< typename T1, typename T2 >
T1* doIt( T2* );
class M {};
class N : public M {};
void f()
{
M* m1 = NULL;
M const* m2 = NULL;
doIt<N>( m1 ); // Fail
doIt<N>( m2 ); // Fail
doIt<N,M>( m1 ); // OK
doIt<N,M>( m2 ); // OK
}
Is this just an error with the Code Warrior compiler? (Or and error with gcc/Visual C++).