<p>Am 26.04.2012 10:45 schrieb "ZHANG Dao-yuan" <<a href="mailto:1123monkey@gmail.com">1123monkey@gmail.com</a>>:<br>
>><br>
>> program moi;<br>
>> {$mode objfpc}<br>
>> uses fgl;<br>
>> type<br>
>> tSI= specialize tFpGMap<integer, tObject>;<br>
>> // tIS= specialize tFpGMap<tObject, integer>;<br>
>> begin<br>
>> end.<br>
><br>
><br>
> Hi,<br>
> I'm trying to use template in fpc 2.6.0. I can map class type as value as above code can be compiled. But if I uncomment the declaration of tIS -- map class type as key, fpc fail to compile and print out these error msgs:<br>
><br>
> Error: Operator is not overloaded: "TObject" < "TObject"<br>
> Error: Operator is not overloaded: "TObject" > "TObject"<br>
> t.pas(10) Fatal: There were 2 errors compiling module, stopping<br>
> Fatal: Compilation aborted<br>
> Error: /usr/bin/ppcx64 returned an error exitcode (normal if you did not specify a source file to be compiled)<br>
><br>
> Any way to resolve it?</p>
<p>This has nothing to do with < and > in the declaration.<br>
TFPGMap uses < and > comparisons for key comparisons, so these operators need to be overloaded. You can't use global operators here, because of scope problems, so you need to use either a different type or wrap them in a record with operators.<br>
<br></p>
<p>Regards,<br>
Sven<br>
</p>