types.d from upstream

This commit is contained in:
Denis Feklushkin 2017-10-18 07:07:36 +07:00
parent da5b87c418
commit fe53b78ba3
1 changed files with 8 additions and 2 deletions

View File

@ -50,12 +50,18 @@ struct Point {
int x;
int y;
Point opBinary(string op)(Point v) if (op == "+") {
Point opBinary(string op)(Point v) const if (op == "+") {
return Point(x + v.x, y + v.y);
}
Point opBinary(string op)(Point v) if (op == "-") {
Point opBinary(string op)(int n) const if (op == "*") {
return Point(x * n, y * n);
}
Point opBinary(string op)(Point v) const if (op == "-") {
return Point(x - v.x, y - v.y);
}
Point opUnary(string op)() const if (op == "-") {
return Point(-x, -y);
}
int opCmp(ref const Point b) const {
if (x == b.x) return y - b.y;
return x - b.x;