With this setup:
template<int N>
struct Base {
void foo();
};
class Derived : Base<1> {
static void bar(Derived *d) {
//No syntax errors here
d->Base<1>::foo();
}
};
Everything works fine. However, with this example:
template<class E>
struct Base {
void foo();
};
template<class E>
class Derived : Base<E> {
static void bar(Derived<E> *d) {
//syntax errors here
d->Base<E>::foo();
}
};
I get:
error: expected primary-expression before '>' token
error: '::foo' has not been declared
What's the difference? Why does the second cause a syntax error?
With the premise that your code compiles fine on Clang 3.2 (see here) and GCC 4.7.2 (see here), I do not see a reason for using
Base<E>::
: just used->foo()
:Alternatively, you could try using the
template
disambiguator: