0

Possible Duplicate:
Where and why do I have to put the “template” and “typename” keywords?

I have a static template method test in class A which takes a single bool template parameter. When I try to call the function like this:

x = A::test<true>(...);

The parser complains as it treats the < as the less than operator. How can I tell the compiler that this is a template instanciation rather than a less than oprator?

Community
  • 1
  • 1
gexicide
  • 38,535
  • 21
  • 92
  • 152

2 Answers2

5
A::template test<true>(...);

read Where and why do I have to put the "template" and "typename" keywords?

Community
  • 1
  • 1
ForEveR
  • 55,233
  • 2
  • 119
  • 133
  • 1
    That should only be needed if `A` is a template parameter (or a dependent type of that). – Xeo Jan 31 '13 at 12:27
2

The template keyword removes the ambiguity.

x = A::template test<true>(...);
eduffy
  • 39,140
  • 13
  • 95
  • 92