>
>
>>> is there way how to declare function, which will accept as parameter any
>>> array type ?
>>> (this parameter I need forward to System.Length() only )
>>
>> Generally one uses TArray<T> as parametertype. in such cases. One can take
>> the length of a generic array.
>
> Hm,
> I do not understand.
>
> I need something like:
>
> function GetLength(const A): integer; inline;
> begin
>   Result := System.Length(A); // of course here I get "Type mismatch"
> end;
>
> Regular function, which I will call from generic object method as far as inside generic object method I can not use System.Length()

Your problem is that you have a Length property in your class, so that's why you need to use System.Length()

Yes

. Try something like this:

=== code begin ===

type
  generic TMyHelper<T> = class
    class function GetLength(aArray: specialize TArray<T>): LongInt;
  end;


When I use:

  generic TLengthHelper<T> = class
class function GetLength(A: specialize T2DArray<T>): Integer; // <-- HERE I get error "Error: expected ;, but T2DArray found"
  end;

Ok, I will leave "Length" and rename it to "Count" ;-)

Thanks
-Laco.

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to