==========
template<typename R, typename T1>
class foo
{
public:
template<typename U, typename T>
void bind(R (U::*)(T1) const, T * obj) { }; // (a)
template<typename U, typename T>
void bind(R (U::*)(T1) const, T & obj) { }; // (b)
};
class bar
{
public:
void foobar(int) const { }
};
int _tmain(int argc, _TCHAR* argv[])
{
foo<void, int> testfoo;
bar * pb = 0;
testfoo.bind(&bar::foobar, pb); // 'error C2668: 'foo<R,T1>::bind' : ambiguous call to' only in VC8
return 0;
}
==========
The above code generate compile error only in VC2005. The same code compile successfuly in VC6, VC2003, DEV C++,
while following two other code snipets compile successfully in VC2005, VC2003, VC6, DEV C++.
==========
class foo
{
public:
template<typename T>
void bind(T * obj) { }; // (a)
template<typename T>
void bind(T & obj) { }; // (b)
};
class bar { };
int _tmain(int argc, _TCHAR* argv[])
{
foo testfoo;
bar * pb = 0;
testfoo.bind(pb); // match (a)
return 0;
}
==========
template<typename R, typename T1>
class foo
{
public:
template<typename U, typename T>
void bind(R (U::*)(T1), T * obj) { }; // (a)
template<typename U, typename T>
void bind(R (U::*)(T1), T & obj) { }; // (b)
};
class bar
{
public:
void foobar(int) { }
};
int _tmain(int argc, _TCHAR* argv[])
{
foo<void, int> testfoo;
bar * pb = 0;
testfoo.bind(&bar::foobar, pb); // match (a)
return 0;
}
==========
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========