need help about get all public static function name
Stanislav Blinov
stanislav.blinov at gmail.com
Mon Oct 22 10:29:56 UTC 2018
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);
}
}
}
}
More information about the Digitalmars-d-learn
mailing list