Get list of public methods of struct

tcak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 9 10:32:41 PST 2017


Is there any way to get list of public methods of a struct?

I looked at both "traits" and "std.traits".

getVirtualFunctions and getVirtualMethods are closest I guess, 
but they don't seem like general purpose due to "Virtual" part. 
(Wouldn't it work if a method was final?)

I saw "FieldNameTuple" in std.traits, but that doesn't seem like 
a proper solution.

I want to use a mixin and foreach to generate a piece of code, 
that selects which method to call based on given parameter. So, 
the generated code will be like,

if( param == "woof" )
     myStruct.woof();
else if( param == "meow" )
     myStruct.meow();

woof and meow are the methods of defined struct.


More information about the Digitalmars-d-learn mailing list