What you linked to is a using directive. A using declaration can be used fine with templated base classes (haven't looked it up in the standard, but just tested it with a compiler):
template<typename T> struct c1 {
void foo() { std::cout << "empty" << std::endl; }
};
template<typename T> struct c2 : c1<T> {
using c1<T>::foo;
void foo(int) { std::cout << "int" << std::endl; }
};
int main() {
c2<void> c;
c.foo();
c.foo(10);
}
The compiler correctly finds the parameter-less foo
function because of our using-declaration re-declaring it into the scope of c2
, and outputs the expected result.
Edit: updated the question. here is the updated answer:
The article is right about that you are not allowed to use a template-id (template name and arguments). But you can put a template name:
struct c1 {
template<int> void foo() { std::cout << "empty" << std::endl; }
};
struct c2 : c1 {
using c1::foo; // using c1::foo<10> is not valid
void foo(int) { std::cout << "int" << std::endl; }
};
int main() {
c2 c;
c.foo<10>();
c.foo(10);
}