G
Gerald Breuer
No, template-methods can't be virtual.
I want to require that every subclass override the method.
template<typename T>
virtual Exception & operator << (const T & value) = 0;
such that the subclass type is guarentee to be returned when the method is
called rather than returning the base class by accident, because someone
forgot to override the method.
I don't buy that particular argument. A template is instantiated for
a finite set of T. If you're not building a library, you even have
control over these Ts.
It would be incompatible with separate compilation. The vtable layout
(which has to be the same for all translation units) would depend upon
the set of classes for which the template is instantiated.
The problem isn't that the set is infinite, but that it's open-ended when
it needs to be fixed.
On Fri, 2013-06-14, Sam wrote:
...
I don't buy that particular argument. A template is instantiated for
a finite set of T. If you're not building a library, you even have
control over these Ts.
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
Wouldn't work with dynamically loadable libraries, where the library is
fixed.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.