On Oct 27, 3:06 pm, mathieu <[EMAIL PROTECTED]> wrote: > Hi there, > > Why do I need the template keyword in this case: > > template <typename T1> > struct A > { > template <typename T2> > void foo() {} > > }; > > template <typename T1> > struct B > { > template <typename T2> > void bar() { > A<T1> a; > // a.foo<T2>(); // does not compile with gcc > a.template foo<T2>(); > } > > }; > > int main() > { > B<int> b; > return 0; > > }
The ".template" tells the compiler that the following less-than symbol (<) is the beginning of a sequence of template arguments, rather than a binary operator. As B::bar is being parsed, the compiler doesn't know whether somebody has done this: template <> struct A<int> { double foo; }; _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus