Ok, so I have finally managed to provide a smallest non-compilable example. I've modified my library a bit and figured out that the compiler has problems with matching parameters to the first overload.
Code:
////////////////////////////////////////////////////////////////////////////////
#include <iostream>
////////////////////////////////////////////////////////////////////////////////
template <class T>
class HelperClass {
};
////////////////////////////////////////////////////////////////////////////////
template <class T>
class BaseClass {
public:
void CallMe()
{
std::cout << "BaseClass::CallMe()" << std::endl;
}
};
////////////////////////////////////////////////////////////////////////////////
template <typename T>
void Foo(T* Ptr, HelperClass<T>* Helper, BaseClass<T>* Base)
{
Base->CallMe();
}
////////////////////////////////////////////////////////////////////////////////
class ClassA : public BaseClass<ClassA> {
public:
};
////////////////////////////////////////////////////////////////////////////////
class ClassB {
public:
};
////////////////////////////////////////////////////////////////////////////////
#ifdef __BORLANDC__
#pragma argsused
#endif
int main(int argc, char* argv[])
{
ClassA* a;
ClassB* b;
HelperClass<ClassA>* helper_a;
HelperClass<ClassB>* helper_b;
std::cout << "Calling Foo(a)..." << std::endl;
Foo<ClassA>(a, helper_a, a); // !A!
std::cout << "Calling Foo(b)..." << std::endl;
Foo<ClassB>(b, helper_b, b); // !B!
std::system("pause");
return 0;
}
////////////////////////////////////////////////////////////////////////////////
I'm getting the following:
Code:
no matching function for call to 'Foo(ClassA*&, HelperClass<ClassA>*&, ClassA*&)'
no matching function for call to 'Foo(ClassB*&, HelperClass<ClassB>*&, ClassB*&)'
The second message is obvious, since ClassB is not a descendant of BaseClass<ClassB>.
But why are there any problems with the first call?
EDIT:
This example does not compile on both compilers, maybe I have missed some standards or there is just an obvious mistake?
EDIT2:
I made a stupid mistake, but it still does not work (updated code).