C ++ Primer 3rd Editionの「関数テンプレート」の章を読んでいます。例に従おうとすると、VC6でのコンパイル中に本でエラーが発生したのとほぼ同じコードが見つかりましたが、g++ではすべて問題ありません。どうしてか分かりません?
コードは次のとおりです。
#include <iostream>
using namespace std;
template<typename T1, typename T2, typename T3>
T1 my_min(T2 a, T3 b)
{
return a>b?b:a;
}
int main()
{
int (*fp)(int, int) = &my_min<int>;
cout<<fp(3,5)<<endl;
return 0;
}
下で発生したエラーは次のVC6ように表示されます。
error C2440: 'initializing' : cannot convert from '' to 'int (__cdecl *)(int,int)'
None of the functions with this name in scope match the target type