Work-around which produces good assembler without writting/reading
intermediate variables:
class function T2DPoint.Sqr(value: T): T; static; inline;
begin
Result := value*value;
end;
function T2DPoint.Distance(P: T2DPoint): Single; inline;
begin
Result := Sqrt(Sqr(x-P.x) + Sqr(y-P.y));
end;
Hi *,
I have generics record, where one method computes distance between 2 points:
function T2DPoint.Distance(P: T2DPoint): Single;
begin
Result := Sqrt(Sqr(x-P.x) + Sqr(y-P.y));
end;
But this does not compile as there are many versions of Sqr() in the
scope Sqr(longint), Sqr(QWord), Sqr(Ext