loop through specific class members
Trass3r
mrmocool at gmx.de
Wed Jan 21 03:48:07 PST 2009
Christopher Wright schrieb:
> On the other hand, you can get the non-final, non-private methods of a
> class with something like:
> foreach (member; __traits (allMembers, Class))
> {
> foreach (overload; __traits (getVirtualFunctions, Class, member))
> {
> // do stuff
> }
> }
>
> Naturally, __traits and foreach don't mix, so you'll have to use
> template recursion. This is pretty damn ugly.
>
But why doesn't that work? It doesn't even work when forced to run at
compile time by CTFE.
Had a look at the compiler code, it uses the same mechanism as
pragma(msg, for example, so shouldn't something like the above
theoretically be possible?
More information about the Digitalmars-d-learn
mailing list