E
Eric
Does anyone know if you can specialize a template function for
arguments that are pointers to a particular base class and not lose
the subclass type?
example:
template <class E>
void DeliverEvent(E *Event);
is a function that will receive an Event object, and then eventually
pass it to the proper destination. To avoid downcasting, any
destination will have a "ReceiveEvent" function that is overloaded for
each specific Event class it is interested in.
There is a particular class of Events, call them "CallEvents", which
require special processing before passing them along. So I want to
specialize the function as such:
template <>
void DeliverEvent(CircuitEvent *Event);
But in doing it this way, the Event object becomes a base class
pointer, and I lose its specific type (and I would like to avoid
downcasting to regain it).
Is there a way to specialize the template function so that my template
argument keeps it type?
Thanks,
Eric Simon
arguments that are pointers to a particular base class and not lose
the subclass type?
example:
template <class E>
void DeliverEvent(E *Event);
is a function that will receive an Event object, and then eventually
pass it to the proper destination. To avoid downcasting, any
destination will have a "ReceiveEvent" function that is overloaded for
each specific Event class it is interested in.
There is a particular class of Events, call them "CallEvents", which
require special processing before passing them along. So I want to
specialize the function as such:
template <>
void DeliverEvent(CircuitEvent *Event);
But in doing it this way, the Event object becomes a base class
pointer, and I lose its specific type (and I would like to avoid
downcasting to regain it).
Is there a way to specialize the template function so that my template
argument keeps it type?
Thanks,
Eric Simon