Am 24.09.2013 11:19, schrieb Xiangrong Fang:
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.
Short answer: No
Long answer: You could try to use TypeInfo(Data) or TypeInfo(T) and use
the returned PTypeInfo to find out the type...
Regards,
Sven
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal