hasAttrib

template hasAttrib () {
enum hasAttrib;
}

Examples

1 enum clot;
2 size_t zlot(string s){ return s.length; }
3 
4 void fnc1() @clot {}
5 void fnc2() @clot @zlot("ok") {}
6 void fnc3() @zlot("abc") {}
7 
8 static assert(  hasAttrib!(clot,fnc1) );
9 static assert(  hasAttrib!(clot,fnc2) );
10 static assert(  hasAttrib!(2,fnc2) );
11 static assert( !hasAttrib!(clot,fnc3) );
12 static assert(  hasAttrib!(3,fnc3) );
13 
14 @clot int var1;
15 @zlot("op") string var2;
16 static assert(  hasAttrib!(clot,var1) );
17 static assert(  hasAttrib!(2,var2) );

Meta