need help about get all public static function name

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


On Monday, 22 October 2018 at 10:45:07 UTC, test wrote:
> 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:
> and

On Monday, 22 October 2018 at 10:45:07 UTC, test wrote:

test1.d
=====================
alias Fn1       = void function();
struct XX {
         alias Fn        = Fn1;
         enum Y {
                 aa
         }
         static void Test(){}
         int id;
}


test2.d
=====================
import test1;
void GetPub(BaseType)(){
         static foreach (name; __traits(allMembers, BaseType)) 
static if( name[0] !is '_' && __traits(getProtection, 
__traits(getMember, BaseType, name)) == "public" ) {
                 static assert( hasMember!(BaseType.init, name));
                 static if( __traits(isStaticFunction, 
__traits(getMember, BaseType, name)) ) {
                         pragma(msg, 
typeof(BaseType.init).stringof ~ "." ~ name);
                 }
         }
}


extern(C) void main(){
         GetPub!XX;
}




More information about the Digitalmars-d-learn mailing list