[fpc-pascal] Use generic class as parameter (was: how to write enumerator for trees)
Xiangrong Fang
xrfang at gmail.com
Fri Mar 22 02:14:51 CET 2013
Hi,
I try to do exactly the same as show here:
QUOTE:
http://svn.freepascal.org/svn/fpc/trunk/packages/fcl-stl/src/gvector.pp
generic TVector<T> = class
... ...
type
TVectorEnumerator = class
private
FVector: TVector;
FPosition: SizeUInt;
FFirstDone: Boolean;
function GetCurrent: T; inline;
public
*constructor Create(AVector: TVector);*
function MoveNext: Boolean; inline;
property Current: T read GetCurrent;
end;
... ...
public
My code:
generic TTreap<TKey, TValue> = class
... ...
type
TTreapEnumerator = class
FStack: TStack;
FCurrent: PNode;
public
*constructor Create(ATreap: TTreap);*
destructor Destroy; override;
function MoveNext: Boolean;
property Current: PNode read FCurrent;
end;
... ...
private
Error message I got is: Error: Generics without specialization cannot
be used as a type for a variable
Then I found this: http://bugs.freepascal.org/view.php?id=19499&history=1
I wonder if this bug's fix is release or not? How does the TVector
class compile with this problem?
Thanks!
Xiangrong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130322/511c91a2/attachment.html>
More information about the fpc-pascal
mailing list