Re: Run-time reflection for class inheritance

2019-12-02 Thread Michael Green via Digitalmars-d-learn
On Sunday, 1 December 2019 at 14:42:46 UTC, Adam D. Ruppe wrote: You can get the type at runtime by simply casting it... if(auto c = cast(EventSocket) event) { // is an event socket } Thanks. I guess you need to be careful about which order you do those tests so as not to cast to more

Re: Run-time reflection for class inheritance

2019-12-01 Thread Michael Green via Digitalmars-d-learn
On Sunday, 1 December 2019 at 12:26:03 UTC, Michael Green wrote: interface Event { [note to self - shouldn't make last minute checks and reverse them by hand before posting] That should of course read: class Event {

Run-time reflection for class inheritance

2019-12-01 Thread Michael Green via Digitalmars-d-learn
I don't know if this would be a sensible approach to try and get at the actual class types for objects stored in some container at runtime? I have noticed that this approach doesn't work if Event is an interface rather than a ancestor class. ``` import std.stdio; import std.string; import