Hello, FPC developers' list
I am trying to understand how to add an enumerator support to the fgl
containers. Seems it is imposible.
I need enumerator to return the same type as generic container. So I
declared enumerator class as generic too. But how to use it inside the
generic container class?
I guessed to use the next construction:
generic TFPGList<T> = class(TFPSList)
type public
TFPGListEnumeratorSpec = specialize TFPGListEnumerator<T>;
....
Everything compiles fine, but when I declare a specialize type for the
generic TFPGList I get very strange compiler errors.
I attached a simple project which exposes the bug.
My fgl patch which I tried to make work is here:
http://www.hu.freepascal.org/fpcircbot/cgipastebin?msgid=18801
Best regards,
Paul Ishenin.
program Project1;
{$mode objfpc}{$H+}
type
{ TFirstGeneric }
generic TFirstGeneric<T> = class(TObject)
private
FSomeValue: Integer;
public
constructor Create;
end;
{ TSecondGeneric }
generic TSecondGeneric<T> = class(TObject)
type public
TFirstGenericType = specialize TFirstGeneric<T>;
function GetFirst: TFirstGenericType;
end;
{ TSecondGeneric }
function TSecondGeneric.GetFirst: TFirstGenericType;
begin
Result := TFirstGenericType.Create;
end;
{ TFirstGeneric }
constructor TFirstGeneric.Create;
begin
FSomeValue := 0;
end;
var
Second: specialize TSecondGeneric<String>;
begin
end.
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel