Find out most derived class in base class

div0 div0 at sourceforge.net
Fri Nov 19 15:03:01 PST 2010


 >On 19/11/2010 21:58, Jonathan M Davis wrote:

> On Friday, November 19, 2010 13:37:45 div0 wrote:
> The type info has information on that type and its base classes, not all of the
> classes in its class hierarchy. That's enough to properly cast the object and
> whatnot, but not enough to enquire about what derived classes may or may not
> exist.
>
> - Jonathan M Davis

Yes, Sorry, I skipped a (rather large) step there. I tend to do that a 
lot, specially when beer is involved. (it's Friday night!).

All the info is available; each typeinfo is compiled into the exe, with 
a specific mangled signature. So on windozes at least it's quite easy 
(in principle ) to query through all symbols, find all the typeinfos and 
so find out all the deriving classes.

Though as you & I both said it's not currently part of the runtime;
and something probably worth adding.

But that's all kind of by the point, the OP was about doing it at 
compile time; which can't be done and seems pointless anyway unless you 
are doing CRTP which involves templates and that also wasn't wanted.

Ergh. I really should ignore this newsgroup on Fridays,
I never get anything useful done! :)

-- 
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk


More information about the Digitalmars-d-learn mailing list