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
  • 37,012
  • 19
  • 88
  • 143

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
  • 53,801
  • 2
  • 106
  • 128
  • 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
  • 37,790
  • 12
  • 92
  • 91