[fpc-pascal] Is it possible to know the data type of a specialized generics class?
Sven Barth
pascaldragon at googlemail.com
Tue Sep 24 13:12:23 CEST 2013
Am 24.09.2013 11:53, schrieb Xiangrong Fang:
>
> But it's not a good idea as you'd still need to convert Data to a
> TObject (e.g. by using a cast), but that will fail if Data is
> something else than a pointer-like type...
>
> This worked in my TTree class (destructor):
>
> if PTypeInfo(TypeInfo(Data))^.Kind = tkObject then TObject(Data).Free;
>
> I don't know in what case it will fail? I tested with a TStringTree,
> could you please give an example that it will fail?
Try something that is not a Pointer, e.g. a Shortstring, a record, or an
ordinal datatype like QWord.
Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130924/bfec2beb/attachment.html>
More information about the fpc-pascal
mailing list