How do I get the following code to compile?
template<typename T> struct A{
template<int x> void foo() { }
};
template <typename T> void bar()
{
A<T> a;
a.foo<22>(); //< error: invalid operands of ... to binary ‘operator<’
}
int main(void)
{
bar<int>();
}
On the line with the error message, I would like to call a.foo
from inside bar
, setting the appropriate template.
Based on the error, the compiler wants to parse the line as (I think):
(a.foo < 22) > ()
How can I get it to parse as a function call and not as a <
?
Seems like something like the most vexing parse but I've never seen it before.