I know that a regular member function of a template class will be created whenever it is used for the first time. But this cannot be done for a virtual member function, since it can be accessed through the base class pointer. Does this mean that virtual member functions will be created as soon as an instance of the template class is created? If not, when?
14.7.1/9 in C ++ 03:
14.7.1/9
An implementation should not implicitly create a function template, a member template, a non-virtual member function, a member class, or a static data member of a class template that does not require instantiation. It is unclear whether the implementation implicitly implements an instance of a virtual member function of a class template if the virtual member function were not created otherwise.
The implementation is determined.
But usually when creating an instance of a class, an entire member is created for the new class type.
In accordance with the C ++ 14.6.4.1/4 standard:
If the virtual function is an implicit instance, its point of immediate execution is the moment the template is created containing the host class specialization.