[fpc-pascal] How can I implement "thrice" in Free Pascal?
Jonas Maebe
jonas.maebe at elis.ugent.be
Tue Oct 18 21:59:42 CEST 2011
On 18 Oct 2011, at 21:55, Sven Barth wrote:
>
> type
> TGenArray<T> = array of T; // this should work in trunk already
>
> function Concat<T>(Arr1, Arr2: TGenArray<T>): TGenArray<T>;
> begin
> SetLength(Result, Length(aArray1) + Length(aArray2));
> if Length(aArray1) > 0 then
> Move(aArray1[0], Result[0], Length(aArray1) * SizeOf(T));
> if Length(aArray2) > 0 then
> Move(aArray2[0], Result[Length(aArray1)], Length(aArray2) * SizeOf(T));
> end;
This implementation will result in crashes if T is a reference-counted type.
Jonas
More information about the fpc-pascal
mailing list