<p>Am 15.04.2014 11:52 schrieb "Xiangrong Fang" <<a href="mailto:xrfang@gmail.com">xrfang@gmail.com</a>>:<br>
> While the following program generate different error:<br>
><br>
> program vectr;<br>
> uses<br>
> treap, vector;<br>
> type<br>
> TNodeHash = specialize TTreap<Integer, string>;<br>
> TNodeVector = class(specialize TVector<TNodeHash>)<br>
> protected<br>
> function OnSort(v1, v2: T): Integer; override;<br>
> end;<br>
><br>
> operator <(nh1, nh2: TNodeHash): Boolean;<br>
> begin<br>
> Result := nh1.Count < nh2.Count;<br>
> end;<br>
> operator >(nh1, nh2: TNodeHash): Boolean;<br>
> begin<br>
> Result := nh1.Count > nh2.Count;<br>
> end;<br>
><br>
> function TNodeVector.OnSort(v1, v2: T): Integer;<br>
> begin<br>
> Result := 0;<br>
> end;<br>
><br>
> begin<br>
> end. <br>
><br>
> gives error message:<br>
><br>
> vector.pas(149,9) Error: Operator is not overloaded: "TTreap$LongInt$AnsiString" < "TTreap$LongInt$AnsiString"<br>
> vector.pas(151,14) Error: Operator is not overloaded: "TTreap$LongInt$AnsiString" > "TTreap$LongInt$AnsiString"<br>
> vectr.lpr(28) Fatal: There were 2 errors compiling module, stopping</p>
<p>Operator overloads must be available in the scope the generic type was *declared* in, not the scope it is *specialized* in. Currently this is only possible by using records that contain operator overloads ("class operator") and using those to specialize the generic. So you'll need to create a container record that contains your TTreap specialization TNodeHash and the operator overloads for > and < and specialize TVector with that.</p>
<p>I have an idea to improve this situation for non-Delphi mode generics, but that wouldn't help you with 2.6.x ;)</p>
<p>> While in my real program, I have this:<br>
><br>
> type<br>
> TCmhWaves = specialize TVector<TCmhWave>; <br>
><br>
> The thing is, even if I do NOT use this definition at all, it still crashes the compiler. By "crash" I mean I get this from lazarus:<br>
><br>
> Compiling wmodel.lError: /usr/bin/ppcx64 can't be executed, error message: Failed to execute "/usr/bin/ppcx64", error code: -139</p>
<p>Is there really a "ppcx64" in /usr/bin? And is it really executable? (try "/usr/bin/ppcx64 -i" in a shell) Also check you Lazarus settings that you've setup the correct "fpc" binary and that you project's target settings are set to the correct platform (maybe you are trying to compile for x86_64 without having a x84_64 compiler installed).</p>
<p>Regards,<br>
Sven</p>