template this and traits getOverloads issue.
Alex Parrill via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Nov 20 06:39:26 PST 2015
Alternatively, you can use a static method and pass in the
instance.
Note that `new B` will print A's members twice, because A's
constructor is always called and `__traits(allMembers, B)`
includes A's members.
---
import std.stdio;
mixin template Bug()
{
import std.traits;
static void bug(T)(T t)
{
writeln(">", T.stringof);
foreach(member; __traits(allMembers, T))
foreach(overload; __traits(getOverloads, T, member))
{
auto dg = &overload;
writeln(member);
}
}
}
class A
{
mixin Bug;
this(){bug!A(this);}
void foo(){}
}
class B: A
{
this(){bug!B(this);}
void bar(){}
void bar(uint a){}
}
void main(){
new A;
new B;
}
More information about the Digitalmars-d-learn
mailing list