[fpc-pascal] Procedural generics question

noreply at z505.com noreply at z505.com
Tue Aug 25 02:25:00 CEST 2020


Inside a generic procedure (no objects used just a procedure) is there a 
way to check which type the code is being used for such as:

generic procedure Add<integer, string>();
begin
   if type = integer then...

   if type = string then...
   begin
     // specialized code for that type only
   end
end;

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

The current way might be to code up separate procedures for each type, 
but that's kind of defeating the purpose of generics since that would 
simply be an overloaded regular function.


More information about the fpc-pascal mailing list