[Lazarus] Helper for arrays
Ondrej Pokorny
lazarus at kluug.net
Sun Oct 2 16:20:33 CEST 2016
On 02.10.2016 16:00, Aradeonas via Lazarus wrote:
> I know I can make helper for array of integer
This is what I thought you want to.
> but I want some helpers for all type of arrays.
Hmmm :( I don't know either.
Maybe you can raise a discussion / feature request in the fpc-devel
mailing list to include type helpers for generic arrays? :
program Project1;
{$mode objfpc}{$H+}
{$modeswitch advancedrecords}
{$modeswitch typehelpers}
type
generic TGenericArray<T> = array of T;
TIntArray = specialize TGenericArray<Integer>;
generic TGenericArrayHelper<T> = type helper for TGenericArray<T>
public
end;
begin
end.
If not added, you'll need to create a generic record wrapper:
program Project1;
{$mode objfpc}{$H+}
{$modeswitch advancedrecords}
{$modeswitch typehelpers}
type
generic TGenericArray<T> = record
private
FArray: array of T;
public
function Count: Integer;
end;
{ TGenericArray }
function TGenericArray.Count: Integer;
begin
Result := Length(FArray);
end;
begin
end.
Ondrej
More information about the Lazarus
mailing list