Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. import std.stdio;
  2. import std.meta;
  3. import std.conv;
  4. import std.typecons;
  5. import std.traits;
  6.  
  7. import core.demangle;
  8.  
  9. import std.datetime;
  10.  
  11.  
  12. struct Vec2
  13. {
  14. alias byRef this;
  15.  
  16. float x;
  17. float y;
  18.  
  19.  
  20. @nogc
  21. ref const(Vec2) byRef() const
  22. {
  23. return this;
  24. }
  25.  
  26. Vec2 opBinary(string op : "+")(ref const(Vec2) a)
  27. {
  28. return Vec2(x + a.x, y + a.y);
  29. }
  30. }
  31.  
  32.  
  33.  
  34. void main()
  35. {
  36.  
  37. Vec2 a = Vec2(10, 20);
  38. Vec2 b = Vec2(3, 3);
  39.  
  40. Vec2 c = a + b;
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement