Trying to use the fgl unit, specifically the TFPGMap.   Below is a simple program I'm trying to compile; it gives me two errors:

fgl.pp(1582,18) Error: Operator is not overloaded: "pair" < "pair"
fgl.pp(1584,23) Error: Operator is not overloaded: "pair" > "pair"


program test;
{$mode objfpc}

uses
  fgl;

type
   pair = record
      x, y : integer;
   end;

operator < (a,b: pair) r:boolean;
begin
   if a.x < a.y then
      r := true
   else
      r := false;
end;

operator > (a,b: pair) r:boolean;
begin
   if a.x > a.y then
      r := true
   else
      r := false;
end;

function cmp(const a,b : pair) : LongInt;
begin
   if a < b then
      cmp := -1
   else
      if a > b then
         cmp := 1
      else
         cmp := 0;
end;

type
  TMyDict = specialize TFPGMap<pair, integer>;
var
  Dict: TMyDict;
  key: pair;
  Value: Integer;
begin
   Dict := TMyDict.Create;
   Dict.OnKeyCompare := @cmp;
   key.x := 2;
   key.y := 4;
   Dict.Add(key, 99);
   Value := Dict[key];
   writeln(Value);
   Dict.Free;
end.

Any advice appreciated. Thanks.

Pete

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to