[fpc-pascal] How to use generics and meta class?
silvioprog
silvioprog at gmail.com
Wed Feb 26 16:16:12 CET 2014
2014-02-25 5:45 GMT-03:00 Sven Barth <pascaldragon at googlemail.com>:
[...]
> So, which syntax to use generic and meta class?
>>
>
> What might work (untested) is this:
>
> === code begin ===
>
> type
>
> generic TMyGeneric<T> = class
> public type
> TMyGenericClass = class of TMyGeneric; // in mode Delphi this would be
> "class of TMyGeneric<T>"
> public
> class procedure RegisterItem(aItemClass: TMyGenericClass);
> end;
>
> === code end ===
>
> Regards,
> Sven
>
Can I use this "metatype" in other class? E.g.:
generic TMyGeneric<T> = class
public type
TMyGenericClass = class of TMyGeneric;
end;
TMyService = class
public
class procedure RegisterItem(aItemClass: TMyGenericClass); // maybe
"aItemClass: TMyGeneric.TMyGenericClass"?
end;
I tried that but:
"Identifier not found "TMyGenericClass"".
--
Silvio Clécio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140226/d71e60a0/attachment.html>
More information about the fpc-pascal
mailing list