次のコードの何が問題になっていますか?
template<typename X>
struct A {
template<int N>
int foo() const {
return N;
}
};
template<typename X>
struct B {
int bar(const A<X>& v) {
return v.foo<13>();
}
};
#include <iostream>
using std::cout;
using std::endl;
int main() {
A<double> a;
B<double> b;
cout << b.bar(a) << endl;
return 0;
}
関数内B::bar
でコンパイラは文句を言います:
エラー:タイプ''および'int'の無効なオペランドから二項'演算子<'</ p>
Aがテンプレートでない場合、すべてが正常にコンパイルされます。