Reputation: 5044
Why does this error appear and how do I fix it?
template<typename T>
struct foo {
template<size_t N>
void hello() {}
};
template<typename T>
struct bar {
void world() {
foo<T> f;
f.hello<0>(); //Error: Expected expression
}
};
Upvotes: 8
Views: 7514
Reputation: 126562
You need to use the template
disambiguator, so the compiler will know that it shall parse hello
as the name of a template member function, and the subsequent <
and >
as angular brackets delimiting the template arguments:
f.template hello<0>();
//^^^^^^^^
Upvotes: 20