我正在尝试编译以下代码:
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();
}
Run Code Online (Sandbox Code Playgroud)
和编译器解释<在T::a<5>作为操作者<,从而导致错误:
invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator<’
Run Code Online (Sandbox Code Playgroud)
有没有办法在T::a<5>没有编译器错误的情况下显式实例化?谢谢.
gcc版本4.5.1 20100924(Red Hat 4.5.1-4)(GCC)