[fpc-pascal] Procedural generics question

leledumbo leledumbo_cool at yahoo.co.id
Tue Aug 25 04:32:38 CEST 2020


> I remember something like this in RTTI though but can't find it in your
docs yet for generics.

{$mode objfpc}

uses
  typinfo;

generic procedure Add<T>;
begin
   if TypeInfo(T) = TypeInfo(Integer) then WriteLn('an integer');
   if TypeInfo(T) = TypeInfo(String) then WriteLn('a string');
end;

begin
  specialize Add<Integer>;
  specialize Add<String>;
end.



--
Sent from: http://free-pascal-general.1045716.n5.nabble.com/


More information about the fpc-pascal mailing list