以下代码不能用G ++ 4.5或4.6(快照)编译。它将使用Digital Mars Compiler 8.42n进行编译。为什么这个小型的C++程序不能用G ++编译?
template <int I>
struct Foo {
template <int J>
void bar(int x) {}
};
template <int I>
void test()
{
Foo<I> a;
a.bar<8>(9);
};
int main(int argc, char *argv[]) {
test<0>();
return 0;
}
的错误信息是:
bugbody.cpp: In function 'void test() [with int I = 0]':
bugbody.cpp:16:11: instantiated from here
bugbody.cpp:11:3: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator<'
是程序有效C++?
[模板函数调用的模板类的C++模板成员函数]的可能重复(http://stackoverflow.com/questions/1840253/c-template-member-function-of-template-class-called-from-模板函数) – 2011-05-04 11:22:35
可能的重复[哪里,为什么我必须把“模板”和“类型名称”依赖名称?](http://stackoverflow.com/questions/610245/where-and-why-do-我必须把模板和类型名称的依赖名称) – 2011-05-04 11:43:15