Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 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 E {}
  17.  
  18. struct A {
  19. int a;
  20.  
  21. @Ref("a")
  22. E b;
  23. E c;
  24. E c1;
  25. E c2;
  26. E c3;
  27. void print() {
  28. static foreach(i, m; A.tupleof)
  29. static if (hasUDA!(m, Ref)) {{
  30. immutable auto n = getUDAs!(m, Ref)[0].n;
  31. __traits(getMember, this, n) *= 2;
  32. }}
  33. }
  34.  
  35. }
  36.  
  37.  
  38. void main()
  39. {
  40. writeln("A.sizeof ", A.sizeof);
  41. auto a = A(1);
  42. writeln(a);
  43.  
  44. a.print();
  45.  
  46. writeln(a);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement