need help about get all public static function name

test test at gmail.com
Mon Oct 22 10:45:07 UTC 2018


On Monday, 22 October 2018 at 10:29:56 UTC, Stanislav Blinov 
wrote:
> On Monday, 22 October 2018 at 10:16:22 UTC, test wrote:
>> I try use traits get all public static function of a struct 
>> pass to template...
>
>> how to do this ?
>
> void allFunctions(T)() {
>     import std.stdio;
>     foreach (name; __traits(allMembers, T)) {
>         static foreach (overload; __traits(getOverloads, T, 
> name)) {
>             static if (__traits(getProtection, overload) == 
> "public" && __traits(isStaticFunction, overload)) {
>                 // 'overload' is an alias to a T's public 
> static function
>                 writeln(name, ": ", typeof(overload).stringof);
>             }
>         }
>     }
> }

On the line: static foreach (overload; __traits(getOverloads, 
Type, name)) , throw error: is not accessible from module


and


More information about the Digitalmars-d-learn mailing list