why MemberFunctionsTuple not support struct ?
Newbie2019
newbie2019 at gmail.com
Tue Jul 30 15:58:21 UTC 2019
On Tuesday, 30 July 2019 at 14:20:41 UTC, CommanderZot wrote:
> Is this what you are looking for?:
>
> alias KillCallback = scope bool delegate();
>
> struct S {
> bool kill() {
> return true;
> }
> }
>
> pragma(msg, typeof(&__traits(getMember, S, "kill")) ); // bool()
> pragma(msg, typeof(KillCallback.init.funcptr)); // bool
> function()
> enum IS_SAME = __traits(isSame, typeof(&__traits(getMember,
> S, "kill")), typeof(KillCallback.init.funcptr) );
>
> static assert(IS_SAME);
Thanks for the tips.
It can not exclude static function, so I replace it with
typeof(&__traits(getMember, S.init, "kill"));
Still, if there is multi kill methods, then I need a array to
handle them.
struct S {
bool kill() {
return true;
}
bool kill(int id) {
return true;
}
}
More information about the Digitalmars-d
mailing list