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
}
};
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>();
//^^^^^^^^
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With