Explicit generic specialization
Original Reporter info from Mantis: okobapatino @OkobaPatino
-
Reporter name: OkobaPatino
Original Reporter info from Mantis: okobapatino @OkobaPatino
- Reporter name: OkobaPatino
Description:
For example, I like to have a generic function and another one handling pointers or arrays. As of now, you can not have two generic methods with the same name that are using each other, and one gets "T" and the other gets "array of T".
For example, you can not do this, but if there was a way to make a version of the method for arrays explicitly, it would be possible.
program Project1;
{$mode delphi}
procedure Test<T>(A: T); overload;
begin
WriteLn(A);
end;
procedure Test<T>(A: array of T); overload;
var
I: Integer;
begin
for I := Low(A) to High(A) do
Test<T>(A[I]);
end;
begin
Test<Integer>(1);
Test<Integer>([1, 2, 3]);
ReadLn;
end.
Additional information:
https://en.cppreference.com/w/cpp/language/template_specialization
Mantis conversion info:
- Mantis ID: 38152
- Version: 3.2.1
- Monitored by: » @OkobaPatino (OkobaPatino)