Am 09.06.2015 11:12 schrieb "aradeonas" <[email protected]>:
>
> Hi,
>
>>
>>   TTestObject = object
>>     i: integer;
>>   end;
>>
>>   TTestObjectList = specialize TFPGList<TTestObject>;
>
>
> When I try to compile this code compiler said :
>
>>
>> Error: Operator is not overloaded: "TTestObject" = "TTestObject"
>
>
> I dont even know what is this mean!

TFPGList<> requires an = operator for the type you want to specialize with.
While you could declare a global operator overload for TTestObject this
won't help as it needs to be a local one. Only records with modeswitch
advancedrecords support this currently, thus you should adjust your code
like this:

=== code begin ===

{$modeswitch advancedrecords} // this needs to be after the $mode, but
before the uses section

type
  TTestObject = record
     i: integer;
      class operator = (const aLeft, aRight: TTestObject): Boolean;
  end;

  TTestObjectList = specialize TFPGList<TTestObject>;

// ...

class operator TTestObject.=(const aLeft, aRight: TTestObject): Boolean;
begin
  // whatever you need for equality
end;

=== code end ===

Regards,
Sven
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to