g++ を使用して Microsoft Visual C++ コードをコンパイルしようとしています。今、私は本当に理解できないコンパイラエラーに遭遇しました。(簡略化された) コードは次のようになります。
template<int X> struct A {
template<class Ret> static Ret call() {
return 0;
}
};
template<int X> struct B : A<X> {
int f() {
return A<X>::call<int>();
}
};
これを g++ (バージョン 4.4.5) でコンパイルしようとすると、次のエラーが発生します。
main.cpp: In member function int B<X>::f():
main.cpp:16: error: expected primary-expression before int
main.cpp:16: error: expected ; before int
main.cpp:16: error: expected unqualified-id before > token
メソッド A::call からテンプレート型 (Ret) を削除すると、コードは正常にコンパイルされます。ここで何が問題なのか誰にもわかりますか?
ありがとう!