[fpc-pascal] Is it possible to know the data type of a specialized generics class?

Xiangrong Fang xrfang at gmail.com
Tue Sep 24 11:19:43 CEST 2013


Hi All,

say, I have a class TTree<T>; in the destructor of that class, is it
possible to know the actual type of T? I want to do things like:

generic TTree<T> = class
public
  Data: T;
  destructor Destroy; override;
end;

destructor TTree.Destroy;
begin
  ... ...
  if Data is TObject then Data.Free;
end;

But "is" does not work with generic types.

Regards,
Xiangrong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130924/40bc75b2/attachment.html>


More information about the fpc-pascal mailing list