Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std.stdio;
- import core.atomic;
- import core.thread;
- import core.sync.mutex;
- import std.datetime.stopwatch;
- import std.concurrency;
- import std.traits;
- import std.random;
- import std.algorithm;
- import std.conv;
- struct Ref{
- string n;
- };
- struct Print{}
- struct E {}
- struct A {
- @Print
- int a;
- @Print
- @Ref("a")
- E b;
- @Print
- @Ref("b")
- E c;
- void print() {
- static foreach(i, m; A.tupleof) {{
- static if (hasUDA!(m, Ref)) {
- immutable auto idx = getUDAs!(m, Ref)[0].n;
- } else {
- immutable auto idx = m.stringof;
- }
- static if (hasUDA!(m, Print)) {
- mixin("writeln("~idx~");");
- }
- }}
- }
- }
- void main()
- {
- auto a = A(1);
- a.print();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement