Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std.stdio;
- import std.meta;
- import std.conv;
- import std.typecons;
- import std.traits;
- import core.demangle;
- import std.datetime;
- struct Vec2
- {
- alias byRef this;
- float x;
- float y;
- @nogc
- ref const(Vec2) byRef() const
- {
- return this;
- }
- Vec2 opBinary(string op : "+")(ref const(Vec2) a)
- {
- return Vec2(x + a.x, y + a.y);
- }
- }
- void main()
- {
- Vec2 a = Vec2(10, 20);
- Vec2 b = Vec2(3, 3);
- Vec2 c = a + b;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement