我试图编译下面的代码:C++编译器将模板语法如“<”操作者
struct A {
template<int N> static void a() {}
};
template<> void A::a<5>() {}
template<class T>
struct B {
static void b() {
T::a<5>();
}
};
void test() {
A::a<5>();
B<A>::b();
}
和编译器在T::a<5>
解释<
作为操作<
,导致错误:
invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator<’
有没有什么办法显式实例化T::a<5>
没有编译错误? 谢谢。
gcc版本4.5.1 20100924(红帽4.5.1-4)(GCC)
[template disambiguator]的可能重复(http://stackoverflow.com/questions/4077110/template-disambiguator) – iammilind