IntPoint / double = IntPoint (should be Point)
Several things are wrong with IntPoint:
#include <iostream>
#include <2geom/int-point.h>
int main()
{
auto result = Geom::IntPoint{230, 231} / 2.3;
static_assert(std::is_same_v<decltype(result), Geom::Point>);
std::cout << result << std::endl;
}
This test program should compile and print (100, 100.4347826086957). However,
-
It doesn't compile, because
IntPointdoesn't have anoperator<<. As a workaround, we can include<2geom/point.h>to usePoint's. -
It doesn't compile, because the
static_assertfails. ChangingPointtoIntPointfixes the compile. -
It prints the wrong answer
(115, 115). This is because the2.3is getting converted to2, and thenIntPoint / int = IntPointis getting used.