Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,35 @@
|
|||
import std.stdio;
|
||||
|
||||
struct S {
|
||||
bool b;
|
||||
|
||||
void foo() {}
|
||||
private void bar() {}
|
||||
}
|
||||
|
||||
class C {
|
||||
bool b;
|
||||
|
||||
void foo() {}
|
||||
private void bar() {}
|
||||
}
|
||||
|
||||
void printProperties(T)() if (is(T == class) || is(T == struct)) {
|
||||
import std.stdio;
|
||||
import std.traits;
|
||||
|
||||
writeln("Properties of ", T.stringof, ':');
|
||||
foreach (m; __traits(allMembers, T)) {
|
||||
static if (__traits(compiles, (typeof(__traits(getMember, T, m))))) {
|
||||
alias typeof(__traits(getMember, T, m)) ti;
|
||||
static if (!isFunction!ti) {
|
||||
writeln(" ", m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
printProperties!S;
|
||||
printProperties!C;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue