<span style="font-family:courier new,monospace">Hi,<br><br>I missed the key point. This bug should be fixed in 2.7.1, but I am now using 2.6.0. Now there is another problem:<br><br>If I change my code to this:<br><br> TTreapEnumerator = class<br>
FStack: TStack;<br> FCurrent: PNode;<br> public<br><span style="color:rgb(255,0,0)"><b> constructor Create(root: PNode);</b></span><br> destructor Destroy; override;<br> function MoveNext: Boolean;<br>
property Current: PNode read FCurrent;<br> end;<br></span><br>The problem is gone, because PNode is not a generic class, but only a record. However, the following errors are generated:<br><br><span style="font-family:courier new,monospace">Error: Forward declaration not solved "constructor THistogram.TTreap$Char$LongInt.TTreapEnumerator.Create(PNode);"<br>
Error: Forward declaration not solved "destructor THistogram.TTreap$Char$LongInt.TTreapEnumerator.Destroy;"<br>Error: Forward declaration not solved "THistogram.TTreap$Char$LongInt.TTreapEnumerator.MoveNext:Boolean;"<br>
<br>THistogram is defined as:<br><br> THistogram = class(specialize TTreap<Char, Integer>)<br> protected<br> function DefaultTraverser(Key: Char; Value: Integer): Boolean; override;<br> procedure DefaultDisposer(Value: Integer); override;<br>
function DefaultUpdater(Key: TKey; Value: TValue; IsNew: Boolean): Boolean; override;<br> public<br> MKey: Char;<br> Max: Integer;<br> constructor Create; override;<br> end; <br><br>I think there is no need to define TTreapEnumerator in THistogram again, right?<br>
<br>Xiangrong<br></span><br><br><div class="gmail_quote">2013/3/22 Xiangrong Fang <span dir="ltr"><<a href="mailto:xrfang@gmail.com" target="_blank">xrfang@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span style="font-family:courier new,monospace">Hi, <br><br>I try to do exactly the same as show here:<br><br><br>QUOTE: <a href="http://svn.freepascal.org/svn/fpc/trunk/packages/fcl-stl/src/gvector.pp" target="_blank">http://svn.freepascal.org/svn/fpc/trunk/packages/fcl-stl/src/gvector.pp</a><br>
</span><pre><span style="font-family:courier new,monospace">generic TVector<T> = class
... ...<br> type
TVectorEnumerator = class
private
FVector: TVector;
FPosition: SizeUInt;
FFirstDone: Boolean;
function GetCurrent: T; inline;
public
<b><span style="color:rgb(255,0,0)">constructor Create(AVector: TVector);</span></b>
function MoveNext: Boolean; inline;
property Current: T read GetCurrent;
end;
... ...
public<br><br>My code:<br><br>generic TTreap<TKey, TValue> = class<br> ... ...<br> type<br> TTreapEnumerator = class<br> FStack: TStack;<br> FCurrent: PNode;<br> public<br> <span style="color:rgb(255,0,0)"><b>constructor Create(ATreap: TTreap);</b></span><br>
destructor Destroy; override;<br> function MoveNext: Boolean;<br> property Current: PNode read FCurrent;<br> end;<br> ... ...<br> private <br><br>Error message I got is: Error: Generics without specialization cannot be used as a type for a variable<br>
<br>Then I found this: </span><span style="font-family:courier new,monospace"><a href="http://bugs.freepascal.org/view.php?id=19499&history=1" target="_blank">http://bugs.freepascal.org/view.php?id=19499&history=1</a><br>
<br>I wonder if this bug's fix is release or not? How does the TVector class compile with this problem?<br>
<br>Thanks!<span class="HOEnZb"><font color="#888888"><br>Xiangrong<br></font></span></span></pre>
</blockquote></div><br>