Is it possible to use the ‘using’ declaration with template base classes? I have read it isn’t here but is that because of a technical reason or is it against the C++ standard, and does it apply to gcc or other compilers? If it is not possible, why not?
Example code (from the link above):
struct A { template<class T> void f(T); }; struct B : A { using A::f<int>; };
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):
The compiler correctly finds the parameter-less
foofunction because of our using-declaration re-declaring it into the scope ofc2, 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: