刚才我已经通过网站挖掘,找出为何模板类模板成员函数是给语法错误:C++模板陷阱
template<class C> class F00 {
template<typename T> bar();
};
...
Foo<C> f;
f.bar<T>(); // syntax error here
我现在认识到模板支架作为关系运算处理。做的目的需要以下离奇的语法,CF Templates: template function not playing well with class's template member function:
f.template bar<T>();
其他什么离奇的方面和C++/C++,你可能遇到了没有的东西,你会认为是常识的模板的疑难杂症?
顺便说一句,你可能只想限制它到模板陷阱,对于一般的C++陷阱已经有另一个问题了。 – int3 2009-12-10 07:22:50
'template bar();'有什么返回类型? –
xtofl
2009-12-10 07:58:48
你错了你的假设。这里你不需要'template',因为'f'不是一个独立的名字。无论如何,它会依赖于什么?这是一个未指定范围的名称,用于“Foo”类型的对象。 –
MSalters
2010-09-22 09:51:14