class P
{
};
template< typename P >
class C : public P
{
public:
void f()
{
P::f();
}
};
int main() {
C<P> c1;
return 0;
}
Just in case my question leaves any room for misunderstanding, here is a code example. If C
was not templated but inherited from P
directly, then the sample would fail to compile because clearly function f()
attempts to call a function on base class P
which is non-existent.
However if C
is templated then this is only picked up if f()
is actually called.
I'd like to know why there is this difference. In both instances f()
would be dead code and stripped anyway, yet the program is ill-formed in the non-template scenario.