09.04.2014 13:55, bearophile пишет:
And you need to use opEquals:
unittest {
static struct Point2D {
double x, y;
bool opEquals(const Point2D rhs) const {
return false;
}
}
auto p2d0 = Point2D(0, 0);
auto p2d1 = Point2D(1, 0);
assert(tween(p2d0, p2d1, 1 / 3.0) == Point2D(1 / 3.0, 0));
}
opEquals/onHash/opCmp are minefields. I don't know why the D compiler
doesn't add a large amount of errors and warnings to turns this
minefield in something a bit safer.
It would be very nice.
Also use std.math.feqrel to compare floating point values.
Thanks!
Bye,
bearophile