[fpc-pascal] Generic TFPGList<Record Type> gives me compiler error: Operator is not overloaded
Sven Barth
pascaldragon at googlemail.com
Tue Sep 17 15:23:01 CEST 2013
On 17.09.2013 14:52, Dennis Poon wrote:
> I have this:
> uses fgl;
>
> Type
> RScene=record
> ID : Word;
> Name, Category : String;
> end;
>
> TSceneList=specialize TFPGList<RScene>;
>
>
> The error is: Operator is not overloaded: "RScene" = "RScene"
>
>
> I suppose the generic thing does not know how to compare 2 records.
> How do I solve that?
Provide a "=" operator overload for the record:
=== code begin ===
uses fgl;
{$modeswitch advanced_records}
Type
RScene=record
ID : Word;
Name, Category : String;
class operator = (aLeft, aRight: RScene): Boolean;
end;
TSceneList=specialize TFPGList<RScene>;
class operator RScene.=(aLeft, aRight: RScene): Boolean;
begin
...
end;
=== code end ===
Regards,
Sven
More information about the fpc-pascal
mailing list