On 2020-08-26 05:44, Nico Neumann via fpc-pascal wrote:
The TypeInfo function checks the code during run-time thus the
generated code is 'bloated'. Better use the compiler intrinsic
GetTypeKind.
{$mode objfpc}
uses
typinfo;
generic procedure Add<T>;
begin
if GetTypeKind(T) = tkInteger then WriteLn('an integer');
if GetTypeKind(T) = tkString then WriteLn('a string');
end;
That's great but if the type is something like a TRec (custom record) or
a class, it won't be possible to check the types AFAICT because those
are special built in type kind values for common basic types?
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal