Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import std.stdio;
  2. import core.atomic;
  3. import core.thread;
  4. import core.sync.mutex;
  5. import std.datetime.stopwatch;
  6. import std.concurrency;
  7. import std.traits;
  8. import std.random;
  9. import std.algorithm;
  10. import std.conv;
  11.  
  12. struct Ref{
  13. string n;
  14. };
  15.  
  16. struct Print{}
  17.  
  18. struct E {}
  19.  
  20. struct A {
  21. @Print
  22. int a;
  23.  
  24. @Print
  25. @Ref("a")
  26. E b;
  27.  
  28. @Print
  29. @Ref("b")
  30. E c;
  31.  
  32. void print() {
  33. static foreach(i, m; A.tupleof) {{
  34. static if (hasUDA!(m, Ref)) {
  35. immutable auto idx = getUDAs!(m, Ref)[0].n;
  36. } else {
  37. immutable auto idx = m.stringof;
  38. }
  39. static if (hasUDA!(m, Print)) {
  40. mixin("writeln("~idx~");");
  41. }
  42. }}
  43. }
  44.  
  45. }
  46.  
  47.  
  48. void main()
  49. {
  50. auto a = A(1);
  51. a.print();
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement