[fpc-pascal] How to use generics and meta class?
    Sven Barth 
    pascaldragon at googlemail.com
       
    Wed Feb 26 17:33:14 CET 2014
    
    
  
Am 26.02.2014 16:16, schrieb silvioprog:
> 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;
>
You'd need something like "aItemClass: specialize 
TMyGeneric<SpecificType>.TMyGenericClass", but that might not compile in 
mode ObjFPC.
As an aside: if TMyGeneric would not be a generic you'd need 
TMyGeneric.TMyGenericClass as well, a TMyGenericClass is part of 
TMyGeneric's scope and TMyService does not know this scope.
Regards,
Sven
    
    
More information about the fpc-pascal
mailing list