【发布时间】:2026-01-24 08:20:03
【问题描述】:
template<typename T>
struct function
{
typedef T type;
template<typename U>
static void f() {}
};
template<typename T>
struct caller
{
int count;
caller(): count() {}
void operator()()
{
count++;
T::f<typename T::type>();
}
};
int main() {
caller<function<int> > call;
call();
return 0;
}
这对我来说似乎是正确的,但是编译器给出了这个我无法理解的丑陋错误:
prog.cpp:在成员函数'void caller::operator()()'中:
prog.cpp:17:错误:预期 `(' 在 '>' 标记之前
prog.cpp:17: 错误: ')' 标记之前的预期主表达式
为了方便起见,代码贴在这里 -> http://www.ideone.com/vtP7G
【问题讨论】: