Dispatching values to handlers, as in std.concurrency
"Luís
"Luís
Mon May 6 10:03:19 PDT 2013
I have a list of functions which receive values of different
types, like in std.concurrency...
// example from std.concurrency
receive(
(int i) { writeln("Received the number ", i);}
);
...although in my case I can probably live by with only accepting
objects.
I built a list of the handlers and the message classes they
accept. My problem is that I don't know how to check if the
message I have to dispatch is of the class the handler accepts
*or a subclass*. I only managed to check for class equality:
if(typeid(msg) == typeHandler.type)
{
typeHandler.handler(msg);
}
How can I also accept subclasses?
Thanks,
Luís
More information about the Digitalmars-d-learn
mailing list